Skip to content

Commit

Permalink
use the last should[not]
Browse files Browse the repository at this point in the history
  • Loading branch information
dchelimsky committed Jan 7, 2009
1 parent 225cdd7 commit 62a41f3
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions lib/spec/matchers/operator_matcher.rb
Expand Up @@ -21,7 +21,7 @@ def initialize(actual)
def self.use_custom_matcher_or_delegate(operator)
define_method(operator) do |expected|
if matcher = OperatorMatcher.get(@actual.class, operator)
return @actual.send(matcher_method, matcher.new(expected))
return @actual.send(::Spec::Matchers.last_should, matcher.new(expected))
else
::Spec::Matchers.last_matcher = self
@operator, @expected = operator, expected
Expand All @@ -45,10 +45,6 @@ def description
end

class PositiveOperatorMatcher < OperatorMatcher #:nodoc:
def matcher_method
:should
end

def __delegate_operator(actual, operator, expected)
return true if actual.__send__(operator, expected)
if ['==','===', '=~'].include?(operator)
Expand All @@ -61,10 +57,6 @@ def __delegate_operator(actual, operator, expected)
end

class NegativeOperatorMatcher < OperatorMatcher #:nodoc:
def matcher_method
:should_not
end

def __delegate_operator(actual, operator, expected)
return true unless actual.__send__(operator, expected)
return fail_with_message("expected not: #{operator} #{expected.inspect},\n got: #{operator.gsub(/./, ' ')} #{actual.inspect}")
Expand Down

0 comments on commit 62a41f3

Please sign in to comment.