[rspec-users] How do I improve the readability of my specs

Nadal node.js99 at gmail.com
Wed May 26 22:37:36 EDT 2010


Here is my spec.

describe Exception2db do
  context "attributes" do
    subject { Exception2db.create(:exception => $exception_data_xml) }

    specify { subject.controller.should == 'exception2db/main' }
    specify { subject.error_message.should == 'RuntimeError: 46' }
    specify { subject.user_agent.should == "Mozilla/5.0 (Macintosh; U;
Intel Mac OS X 10_6_3; en-US) AppleWebKit/533.4 (KHTML, like Gecko)
Chrome/5.0.375.38 Safari/533.4" }
  end
end

Here is specdoc.

Exception2db attributes
- should == "exception2db/main"
- should == "RuntimeError: 46"
- should == "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-US)
AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.38 Safari/533.4"

All the tests are passing. However the specdoc message is not very
clean.

How can I improve the message? What am I missing? The idea of wrapping
each of my specify inside "it" to just to have better message is not
very DRY.



More information about the rspec-users mailing list