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

About alx

One Response to “[Ruby] Behaviour Driven Development with RSpec”

Leave a Reply

  • (will not be published)