Copied from Railsware#blog
What I also like in RSpec is that it constructs a name for simplistics specifications, like:
context "Random number in 0..100 range" do
setup do
@random_number = rand(100)
end
specify do
@random_number.should < 100
end
specify do
@random_number.should >= 0
end
specify do
@random_number.should_not be_nil
end
end
Random number in 0..100 range - should < 100 - should >= 0 - should not be nil
Update:
I’ve played around matchers to make generated names work properly for be_ matchers (like be_between): http://blog.railsware.com/2007/3/2/rspec-generated-spec-name-for-be (and it’s accepted in rspec trunk now)




