Rspec has a really cool feature where, if you assert that something
should be_something_else it'll assume there's a method called
something_else?

So for example;

Suppose you had a model called Sushi.

In your spec you could write:

describe Sushi do

  it "should be awesome"
    @sushi.should be_awesome
  end

end

This will assume there is a method called awesome? available to @sushi
and will call it and expect it to return true.

ActiveRecord::Base, which all of your models will inherit from has a
method called "new_record?".
By using "@model.should be_new_record" or "@model.should
be_a_new_record" you're essentially saying that the new_record? method
should be called and should return true.

If you're getting a NoMethod error specifically on "be_a_new_record"
then you might want to ensure you have the latest versions of rspec
and rspec-rails.

Hope that helps?

Gavin

http://handyrailstips.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to