Module: Surrogate::RSpec::MatchNumTimesWith

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.



152
153
154
# File 'lib/surrogate/rspec/api_method_matchers.rb', line 152

def expected_arguments
  @expected_arguments
end

#expected_times_invokedObject

Returns the value of attribute expected_times_invoked.



152
153
154
# File 'lib/surrogate/rspec/api_method_matchers.rb', line 152

def expected_times_invoked
  @expected_times_invoked
end

Class Method Details

.extended(klass) ⇒ Object



148
149
150
# File 'lib/surrogate/rspec/api_method_matchers.rb', line 148

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

Instance Method Details

#actual_invocationObject



162
163
164
165
# File 'lib/surrogate/rspec/api_method_matchers.rb', line 162

def actual_invocation
  return message_for :other, :not_invoked if times_invoked.zero?
  "#{message_for :other, :invoked_description} #{times_msg times_invoked_with_expected_args}"
end

#match?Boolean

Returns:

  • (Boolean)


158
159
160
# File 'lib/surrogate/rspec/api_method_matchers.rb', line 158

def match?
  times_invoked_with_expected_args == expected_times_invoked
end

#times_invoked_with_expected_argsObject



154
155
156
# File 'lib/surrogate/rspec/api_method_matchers.rb', line 154

def times_invoked_with_expected_args
  invocations.select { |invocation| invocation == expected_arguments }.size
end