[rspec-users] Question: Define custom matcher like raise_error, by Matchers.define
pub at kaorukobo.net
Thu Nov 25 00:09:00 EST 2010
I have a question about the custom matcher using Matcher#define.
My intention is given by the following code:
Spec::Matchers.define :be_done do
match do |block|
describe "The expectation failure in block called from the custom
example "should be reported." do
1.should == 2
}.should_not raise_error(/be_done failed/) # should 'expected:
2, got: 1 (using ==)'
I want to define the custom matcher that it calls the block given as
the actual value, like raise_error.
But if the expectation in the given block failed,
it is not reported, but it reports the custom matcher's failure.
Is there some misuse about Matchers.define in my code?
More information about the rspec-users