Sha256: bc19d184a799be5cd9c4e6b21b11b424a7a9afee21b932d6eed746d8faf3e6d5
Contents?: true
Size: 1.83 KB
Versions: 18
Compression:
Stored size: 1.83 KB
Contents
module Rspec module Expectations class InvalidMatcherError < ArgumentError; end class PositiveExpectationHandler def self.handle_matcher(actual, matcher, message=nil, &block) ::Rspec::Matchers.last_should = :should ::Rspec::Matchers.last_matcher = matcher return ::Rspec::Matchers::PositiveOperatorMatcher.new(actual) if matcher.nil? match = matcher.matches?(actual, &block) return match if match message ||= matcher.respond_to?(:failure_message_for_should) ? matcher.failure_message_for_should : matcher.failure_message if matcher.respond_to?(:diffable?) && matcher.diffable? ::Rspec::Expectations.fail_with message, matcher.expected.first, matcher.actual else ::Rspec::Expectations.fail_with message end end end class NegativeExpectationHandler def self.handle_matcher(actual, matcher, message=nil, &block) ::Rspec::Matchers.last_should = :should_not ::Rspec::Matchers.last_matcher = matcher return ::Rspec::Matchers::NegativeOperatorMatcher.new(actual) if matcher.nil? match = matcher.respond_to?(:does_not_match?) ? !matcher.does_not_match?(actual, &block) : matcher.matches?(actual, &block) return match unless match message ||= matcher.respond_to?(:failure_message_for_should_not) ? matcher.failure_message_for_should_not : matcher.negative_failure_message if matcher.respond_to?(:diffable?) && matcher.diffable? ::Rspec::Expectations.fail_with message, matcher.expected.first, matcher.actual else ::Rspec::Expectations.fail_with message end end end end end
Version data entries
18 entries across 18 versions & 1 rubygems