Class: RSpec::Crispy::CrispyFeatures::CrispyHaveReceived::NTimes
Instance Method Summary
collapse
#actually_received_messages_for_failure_message, #matches?, #name, #once, #spy_of_subject, #times
Constructor Details
#initialize(n, method_name, *arguments) ⇒ NTimes
Returns a new instance of NTimes.
104
105
106
107
|
# File 'lib/rspec/crispy/crispy_features.rb', line 104
def initialize n, method_name, *arguments
super(method_name, *arguments)
@n = n
end
|
Instance Method Details
#failure_message ⇒ Object
114
115
116
117
118
119
120
121
122
123
|
# File 'lib/rspec/crispy/crispy_features.rb', line 114
def failure_message
@spy_of_subject.stop
result = "Expected #{@subject.inspect} to have received :#@method_name method"
result << " with #@arguments" unless @arguments.empty?
result << " some particular times.\n"
result << " Expected: #@n times.\n"
result << " Actual: #@actual_count times.\n"
result << actually_received_messages_for_failure_message
result
end
|
#failure_message_when_negated ⇒ Object
125
126
127
128
129
130
131
132
|
# File 'lib/rspec/crispy/crispy_features.rb', line 125
def failure_message_when_negated
@spy_of_subject.stop
result = "Expected #{@subject.inspect} to have received :#@method_name method"
result << " with #@arguments" unless @arguments.empty?
result << " NOT #@n times.\n"
result << actually_received_messages_for_failure_message
result
end
|
#matched_spy?(spy) ⇒ Boolean
109
110
111
112
|
# File 'lib/rspec/crispy/crispy_features.rb', line 109
def matched_spy? spy
@actual_count = spy.count_received(@method_name, *@arguments)
@n == @actual_count
end
|