3 ms·
RSpec 2 introduced an eq matcher so you can do this warning free: i.porkchop_sandwiches.count.should eq(1). Then for object identity you can still use be:
by dchelimsky 16y ago
RSpec 2 introduced an eq matcher so you can do this warning free:
i.porkchop_sandwiches.count.should eq(1).
Then for object identity you can still use be:
i.porkchop_sandwiches.first.should be(my_sandwich)
This is actually more in line with the original RSpec, which had should_equal and should_be, and I prefer it because you eliminate the warning, and (I think that) "1.should eq(1)" actually speaks better than "1.should == 1" for someone familiar with ruby but new to RSpec.
- petercooper 16y agoFair enough, though I know what == means in Ruby and eq is additional, duplicated syntax to learn (as with assert_equals). Without hitting the docs, I wonder what the other comparisons are in this alternate DSL. I could have a good guess.. lt, gt.. not sure on less than or equal to, regex matching, etc. I'd have to look up or memorize those rather than use syntax reinforced over years of use that already does the job. How something sounds is not so important to me, AppleScript swore me off the "sounds like English" route :-) Naturally this is a matter of opinion, but it's testament to your fine work with RSpec (and particularly in the recent modularization work) that it deals deftly with differing opinions without putting anyone at a serious disadvantage.
- dchelimsky 16y agoThanks for the props. The other operators are still supported as/is and don't cause the warning that == does.