Class Spec::Matchers::Matcher

  1. lib/spec/matchers/matcher.rb
Parent: Object

Attributes

actual [R]
expected [R]

Public class methods

new (name, *expected, &declarations)
[show source]
# File lib/spec/matchers/matcher.rb, line 10
      def initialize(name, *expected, &declarations)
        @name     = name
        @expected = expected
        @actual   = nil
        @diffable = false
        @messages = {
          :description => lambda {"#{name_to_sentence}#{expected_to_sentence}"},
          :failure_message_for_should => lambda {|actual| "expected #{actual.inspect} to #{name_to_sentence}#{expected_to_sentence}"},
          :failure_message_for_should_not => lambda {|actual| "expected #{actual.inspect} not to #{name_to_sentence}#{expected_to_sentence}"}
        }
        making_declared_methods_public do
          instance_exec(*@expected, &declarations)
        end
      end

Public instance methods

description (&block)
[show source]
# File lib/spec/matchers/matcher.rb, line 29
      def description(&block)
        cache_or_call_cached(:description, &block)
      end
diffable ()
[show source]
# File lib/spec/matchers/matcher.rb, line 49
      def diffable
        @diffable = true
      end
diffable? ()
[show source]
# File lib/spec/matchers/matcher.rb, line 45
      def diffable?
        @diffable
      end
failure_message_for_should (&block)
[show source]
# File lib/spec/matchers/matcher.rb, line 33
      def failure_message_for_should(&block)
        cache_or_call_cached(:failure_message_for_should, actual, &block)
      end
failure_message_for_should_not (&block)
[show source]
# File lib/spec/matchers/matcher.rb, line 37
      def failure_message_for_should_not(&block)
        cache_or_call_cached(:failure_message_for_should_not, actual, &block)
      end
match (&block)
[show source]
# File lib/spec/matchers/matcher.rb, line 41
      def match(&block)
        @match_block = block
      end
matches? (actual)
[show source]
# File lib/spec/matchers/matcher.rb, line 25
      def matches?(actual)
        instance_exec(@actual = actual, &@match_block)
      end