Browse files

Fix RSpec::Matchers::DSL#define for compatibility with 1.8.x

  • Loading branch information...
1 parent abba439 commit 21752df73e712c5c0f85ece3474736afe2be4b27 mirasrael committed Mar 31, 2012
Showing with 4 additions and 2 deletions.
  1. +4 −2 lib/rspec/matchers/dsl.rb
View
6 lib/rspec/matchers/dsl.rb
@@ -4,9 +4,11 @@ module DSL
# Defines a custom matcher.
# @see RSpec::Matchers
def define(name, &declarations)
- matcher = RSpec::Matchers::DSL::Matcher.new(name, &declarations)
+ template_matcher = RSpec::Matchers::DSL::Matcher.new(name, &declarations)
define_method name do |*expected|
- matcher.for_expected(*expected).tap { |m| m.matcher_execution_context = @matcher_execution_context || self }
+ matcher = template_matcher.for_expected(*expected)
+ matcher.matcher_execution_context = @matcher_execution_context || self
+ matcher
end
end

0 comments on commit 21752df

Please sign in to comment.