Class Spec::Mocks::ArgumentExpectation

  1. lib/spec/mocks/argument_expectation.rb
Parent: Object

Attributes

args [R]

Public class methods

new (args, &block)
[show source]
# File lib/spec/mocks/argument_expectation.rb, line 7
      def initialize(args, &block)
        @args = args
        @matchers_block = block
        
        if ArgumentMatchers::AnyArgsMatcher === args.first
          @match_any_args = true
        elsif ArgumentMatchers::NoArgsMatcher === args.first
          @matchers = []
        else
          @matchers = args.collect {|arg| matcher_for(arg)}
        end
      end

Public instance methods

args_match? (given_args)
[show source]
# File lib/spec/mocks/argument_expectation.rb, line 30
      def args_match?(given_args)
        match_any_args? || matchers_block_matches?(given_args) || matchers_match?(given_args)
      end
is_matcher? (obj)
[show source]
# File lib/spec/mocks/argument_expectation.rb, line 26
      def is_matcher?(obj)
        return obj.respond_to?(:matches?) & obj.respond_to?(:description)
      end
match_any_args? ()
[show source]
# File lib/spec/mocks/argument_expectation.rb, line 42
      def match_any_args?
        @match_any_args
      end
matcher_for (arg)
[show source]
# File lib/spec/mocks/argument_expectation.rb, line 20
      def matcher_for(arg)
        return ArgumentMatchers::MatcherMatcher.new(arg)   if is_matcher?(arg)
        return ArgumentMatchers::RegexpMatcher.new(arg) if arg.is_a?(Regexp)
        return ArgumentMatchers::EqualityProxy.new(arg)
      end
matchers_block_matches? (given_args)
[show source]
# File lib/spec/mocks/argument_expectation.rb, line 34
      def matchers_block_matches?(given_args)
        @matchers_block ? @matchers_block.call(*given_args) : nil
      end
matchers_match? (given_args)
[show source]
# File lib/spec/mocks/argument_expectation.rb, line 38
      def matchers_match?(given_args)
        @matchers == given_args
      end