Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #126 from mirasrael/master

Fix for error with using custom matchers inside other custom matchers
  • Loading branch information...
commit 6fe6c9fa1c6ad1230a811d4144e4b33237d1e2d9 2 parents 0458ac1 + 77243d9
David Chelimsky dchelimsky 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
2  lib/rspec/matchers/matcher.rb
View
@@ -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
12 spec/rspec/matchers/dsl_spec.rb
View
@@ -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.