Parent

Files

RSpec::Mocks::ArgumentExpectation

@api private

Attributes

args[R]

Public Class Methods

new(*args, &block) click to toggle source
# File lib/rspec/mocks/argument_expectation.rb, line 7
def initialize(*args, &block)
  @args = args
  @block = args.empty? ? block : nil
  @match_any_args = false
  @matchers = nil
  
  case args.first
  when ArgumentMatchers::AnyArgsMatcher
    @match_any_args = true
  when ArgumentMatchers::NoArgsMatcher
    @matchers = []
  else
    @matchers = args.collect {|arg| matcher_for(arg)}
  end
end

Public Instance Methods

args_match?(*args) click to toggle source
# File lib/rspec/mocks/argument_expectation.rb, line 33
def args_match?(*args)
  match_any_args? || block_passes?(*args) || matchers_match?(*args)
end
is_matcher?(obj) click to toggle source
# File lib/rspec/mocks/argument_expectation.rb, line 29
def is_matcher?(obj)
  !null_object?(obj) & obj.respond_to?(:matches?) & [:failure_message_for_should, :failure_message].any? { |m| obj.respond_to?(m) }
end
matcher_for(arg) click to toggle source
# File lib/rspec/mocks/argument_expectation.rb, line 23
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

[Validate]

Generated with the Darkfish Rdoc Generator 2.