Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix error with using custom matchers inside other custom matcher rspe…

  • Loading branch information...
commit 77243d92b328a609f46d7ce3036ca92de9b427ef 1 parent 0458ac1
mirasrael authored
Showing with 13 additions and 1 deletion.
  1. +1 −1  lib/rspec/matchers/matcher.rb
  2. +12 −0 spec/rspec/matchers/dsl_spec.rb
View
2  lib/rspec/matchers/matcher.rb
@@ -222,7 +222,7 @@ def does_not_match?(actual)
end
def respond_to?(method, include_private=false)
- $matcher_execution_context.respond_to?(method, include_private) || super
+ $matcher_execution_context != self && $matcher_execution_context.respond_to?(method, include_private) || super
end
private
View
12 spec/rspec/matchers/dsl_spec.rb
@@ -5,6 +5,18 @@ def question?
:answer
end
+ it "able to use custom matchers inside custom matcher" do
+ RSpec::Matchers.define :be_ok do
+ match { |actual| actual.should == "ok" }
+ end
+
+ RSpec::Matchers.define :be_well do
+ match { |actual| actual.should be_ok }
+ end
+
+ "ok".should be_well
+ end
+
it "has access to methods available in the scope of the example" do
RSpec::Matchers::define(:ignore) {}
ignore.question?.should eq(:answer)
Please sign in to comment.
Something went wrong with that request. Please try again.