.should
is not vanilla ruby - it is rspec just like expect
...
rspec
introduced the expect
syntax, because of inherent caveats in the should
method:
Delegation Issues Between
method_missing
,BasicObject
and the standard library’s delegate, ruby has very rich tools for building delegate or proxy objects. Unfortunately, RSpec’sshould
syntax, as elegantly as it reads, is prone to producing weird, confusing failures when testing delegate/proxy objects.
Rspec API guidelines is to have tests read like english, that is why they have syntax like:
object.should have(5).elements
Or with the new syntax
expect(object).to have(5).elements
Which means that you "expect object to have 5 elements", instead of having to explain the same this with
object.size.should == n