list of predefined variables

ronald Jun 10, 2009

$! The exception information message set by 'raise'. $@ Array of backtrace of the last exception thrown.

$&         The string matched by the last successful pattern match in this scope.
$`         The string to the left  of the last successful match.
$'         The string to t...

A typical usage for a mock

hosiawak Jun 4, 2009 2 thanks

You want to use a mock when you're testing a behaviour of one of your methods that interacts with some outside world service (eg. an FTP server).

it "should login to ftp server" do ftp = mock('Ftp server', :null_object => true) Net::FTP.should_receive(:new).and_return(ftp) ftp.sho...

example

ronald Jun 4, 2009 2 thanks

==== Ruby style Dir[File.join(RAILS_ROOT, 'vendor', 'plugins', '')] ==== Rails style Dir[Rails.root.join('vendor', 'plugins', '')]

Do not create an [ ] method

THAiSi Jun 2, 2009 1 thank

I created a helper method to access some meta data using

def [](name)
# do stuff
end

This breaks ActiveRecord behaviors. all belongs_to relations were broken

eg.

class Image
belongs_to :album
end

i = Image.find :first
i.album_id # 1
i.album # nil

Album...