Sha256: 878263ae597e39730618edf06280b8b146e484389a9a896ecc8acc429acc3b0a

Contents?: true

Size: 1005 Bytes

Versions: 7

Compression:

Stored size: 1005 Bytes

Contents

module Spec
  module Expectations
    class InvalidMatcherError < ArgumentError; end        
    
    class ExpectationMatcherHandler        
      def self.handle_matcher(actual, matcher, &block)
        ::Spec::Matchers.last_should = :should
        ::Spec::Matchers.last_matcher = matcher

        return ::Spec::Matchers::PositiveOperatorMatcher.new(actual) if matcher.nil?

        match = matcher.matches?(actual, &block)
        ::Spec::Expectations.fail_with(matcher.failure_message) unless match
        match
      end
    end

    class NegativeExpectationMatcherHandler
      def self.handle_matcher(actual, matcher, &block)
        ::Spec::Matchers.last_should = :should_not
        ::Spec::Matchers.last_matcher = matcher

        return ::Spec::Matchers::NegativeOperatorMatcher.new(actual) if matcher.nil?
        
        match = matcher.matches?(actual, &block)
        ::Spec::Expectations.fail_with(matcher.negative_failure_message) if match
        match
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 5 rubygems

Version Path
dchelimsky-rspec-1.1.11.7 lib/spec/expectations/handler.rb
dchelimsky-rspec-1.1.12 lib/spec/expectations/handler.rb
newbamboo-evented-rspec-1.1.12 lib/spec/expectations/handler.rb
newbamboo-rspec-1.1.12 lib/spec/expectations/handler.rb
mack-0.8.3 lib/gems/rspec-1.1.12/lib/spec/expectations/handler.rb
mack-0.8.3.1 lib/gems/rspec-1.1.12/lib/spec/expectations/handler.rb
rspec-1.1.12 lib/spec/expectations/handler.rb