-
Website
http://blog.new-bamboo.co.uk -
Original page
http://blog.new-bamboo.co.uk/2007/02/25/defining-interfaces-through-mocking -
Subscribe
All Comments -
Community
-
Top Commenters
-
coupde
1 comment · 1 points
-
TomK32
1 comment · 1 points
-
prateekdayal
1 comment · 1 points
-
andycroll
1 comment · 1 points
-
drnic
1 comment · 6 points
-
-
Popular Threads
One hiccup I ran into was that you never explicitly point out that we need to execute the migration. Of course, it's obvious now, but when you're focusing on shiny new things, the obvoius can go unnoticed :)
Anyway, if anyone else gets:
ActiveRecord::StatementInvalid in 'A general auction should have errors given invalid values'
ActiveRecord::StatementInvalid
./spec/models/auction_spec.rb:31:in `new'
./spec/models/auction_spec.rb:31:
just run 'rake db:migrate' and all becomes well.
Thanks again.
One thing that caught be attention were your expectations. For instance:
@auction.valid?.should_equal false
Could be written like this:
@auction.should_not_be_valid
Rspec is clever enough (using method_missing) to run the method :valid? on the @auction object and make sure its false (because of the should_not). I find its cleaner that way and it will also take advantage of Rspec's new generated spec names feature.
<pre>
specify "should be able to deactivate auction" do
@auction.attributes = AuctionSpecHelper.valid_auction_attributes
@auction.deactivate!
@auction.activated?.should_equal false
end
</pre>
@eric - Easy tiger, I'll get onto different expectation vocabulary together with more advanced parts of RSpec and use of mocking in the next article.:)
I had to add the column 'owner' to the auction model to get the last test:
"context "An auction with an owner" do"
to pass. Otherwise it was failing with no such method owner= for the auction model class.
Is this necessary or is there another way to get this test to pass?
Thanks.