ashley.moran at patchspace.co.uk
Mon Nov 30 06:45:35 EST 2009
On Nov 29, 2009, at 6:33 am, rogerdpack wrote:
> It is somewhat surprising to me, as a newbie, to have to assert
> a.should be_a(Hash)
Once you see the matcher (ie be_a) as something that returns a matcher object, it makes a lot more sense. My brain is now wired to give much more weight to the thing on the right.
You might find it instructive/enlightening/life-changing (possibly) to have a go at writing some custom matchers. From the RSpec docs:
which is implemented with ->
Spec::Matchers.define :be_in_zone do |zone|
match do |player|
Although I've just realised that RSpec's dynamic be_* matcher actually gives you that for free...
More information about the rspec-users