I have been using rspec for a little while and recently switched style from
it "should do something cool" do
@something.should work
end
to the more concise
subject(@something)
it {should work}
Whilst I much prefer the more concise style when writing the tests and for viewing them in code, I miss being able to specify the description for each test, particularly since the equality messages just display the values that are being tested. So in the example above, assuming the test passes, with the first style, I would get a message saying ‘it should do something cool’, whereas the second will just say that it has worked.
Does anyone know of a way to do this? Cheers
I think you got the wrong concept of what the
specify/subjectblocks do. They are not meant to be a complete replacement for the more verbose syntax you switched from, but should be used when there is no need for a desciption.So if you want a desciption, just use
Also, I personally don’t think that the
specify/subjectis more concise. For me it’s a step away from the more DSL-like way specifications created with rspec read, but that might be a matter of personal preference.