During the rewritting of Feevy.com with Merb, I’m discovering RSpec, a framework to be sure your code behave nicely.
Follow and join Feevy rewrite on Gitorious
Instead of normal test-units, you describe how your app/model should behave, which give a more-human conversation when you read your test:
it "should create a feed from website http://blog.feevy.com" do
feed = Feed.new :website => "http://blog.feevy.com"
feed.valid?(:save).should == true
feed.link.should == "http://blog.feevy.com/feed/"
feed.website.should == "http://blog.feevy.com"
feed.title.should == "Feevy Blog"
end
To re-initialize your database between each test:
before(:each) do
Feed.delete_all
end
Next step: writing Feevy stories










1 Commento
Are you sure you need the before do { Feed.delete_all } ? RSpec should be reloading the db from fixtures (if you’re using them) between each test.