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|
    block.call
    true
  end

  failure_message_for_should do
    "be_done failed."
  end
end

describe "The expectation failure in block called from the custom matcher" do
  example "should be reported." do
    lambda {
      lambda {
        1.should == 2
      }.should be_done
}.should_not raise_error(/be_done failed/) # should 'expected: 2, got: 1 (using ==)'
  end
end
========================================================================

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?

Best Regards.
--
Kaoru Kobo

_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to