Module: Surrogate::RSpec::MatchWithArguments

Defined in:
lib/surrogate/rspec/api_method_matchers.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#expected_argumentsObject

Returns the value of attribute expected_arguments.



116
117
118
# File 'lib/surrogate/rspec/api_method_matchers.rb', line 116

def expected_arguments
  @expected_arguments
end

Class Method Details

.extended(klass) ⇒ Object



112
113
114
# File 'lib/surrogate/rspec/api_method_matchers.rb', line 112

def self.extended(klass)
  klass.message_type = :with
end

Instance Method Details

#actual_invocationObject



126
127
128
129
130
# File 'lib/surrogate/rspec/api_method_matchers.rb', line 126

def actual_invocation
  return message_for :other, :not_invoked if times_invoked.zero?
  inspected_invocations = invocations.map { |invocation| inspect_arguments invocation }
  "got #{inspected_invocations.join ', '}"
end

#match?Boolean

eventually this will need to get a lot smarter

Returns:

  • (Boolean)


118
119
120
121
122
123
124
# File 'lib/surrogate/rspec/api_method_matchers.rb', line 118

def match? # eventually this will need to get a lot smarter
  if expected_arguments.size == 1 && expected_arguments.first.kind_of?(::RSpec::Mocks::ArgumentMatchers::NoArgsMatcher)
    invocations.include? []
  else
    invocations.include? expected_arguments
  end
end