Class: FlexMock::RSpecMatchers::HaveReceived
Instance Method Summary
collapse
#append_call_record, #block_description, #describe_calls, #describe_spy, #describe_spy_expectation, #describe_spy_negative_expectation, #spy_description, #times_description
Constructor Details
#initialize(method_name) ⇒ HaveReceived
Returns a new instance of HaveReceived.
9
10
11
12
13
14
15
16
|
# File 'lib/flexmock/rspec_spy_matcher.rb', line 9
def initialize(method_name)
@method_name = method_name
@args = nil
@block = nil
@times = nil
@needs_block = nil
@additional_validations = []
end
|
Instance Method Details
#and(&block) ⇒ Object
81
82
83
84
|
# File 'lib/flexmock/rspec_spy_matcher.rb', line 81
def and(&block)
@additional_validations << block
self
end
|
#construct_options ⇒ Object
86
87
88
89
90
91
92
93
|
# File 'lib/flexmock/rspec_spy_matcher.rb', line 86
def construct_options
{
:times => @times,
:with_block => @needs_block,
:on_count => @on_count,
:and => @additional_validations,
}
end
|
#description ⇒ Object
40
41
42
|
# File 'lib/flexmock/rspec_spy_matcher.rb', line 40
def description
spy_description(@spy, @method_name, @args, @options)
end
|
#failure_message ⇒ Object
28
29
30
|
# File 'lib/flexmock/rspec_spy_matcher.rb', line 28
def failure_message
describe_spy_expectation(@spy, @method_name, @args, @options)
end
|
#failure_message_for_should ⇒ Object
24
25
26
|
# File 'lib/flexmock/rspec_spy_matcher.rb', line 24
def failure_message_for_should
failure_message
end
|
#failure_message_for_should_not ⇒ Object
32
33
34
|
# File 'lib/flexmock/rspec_spy_matcher.rb', line 32
def failure_message_for_should_not
failure_message_when_negated
end
|
#failure_message_when_negated ⇒ Object
36
37
38
|
# File 'lib/flexmock/rspec_spy_matcher.rb', line 36
def failure_message_when_negated
describe_spy_negative_expectation(@spy, @method_name, @args, @options)
end
|
#matches?(spy) ⇒ Boolean
18
19
20
21
22
|
# File 'lib/flexmock/rspec_spy_matcher.rb', line 18
def matches?(spy)
@spy = spy
@options = construct_options
@spy.flexmock_received?(@method_name, @args, @options)
end
|
64
65
66
|
# File 'lib/flexmock/rspec_spy_matcher.rb', line 64
def never
times(0)
end
|
#on(on_count) ⇒ Object
76
77
78
79
|
# File 'lib/flexmock/rspec_spy_matcher.rb', line 76
def on(on_count)
@on_count = on_count
self
end
|
68
69
70
|
# File 'lib/flexmock/rspec_spy_matcher.rb', line 68
def once
times(1)
end
|
59
60
61
62
|
# File 'lib/flexmock/rspec_spy_matcher.rb', line 59
def times(n)
@times = n
self
end
|
72
73
74
|
# File 'lib/flexmock/rspec_spy_matcher.rb', line 72
def twice
times(2)
end
|
#with(*args) ⇒ Object
44
45
46
47
|
# File 'lib/flexmock/rspec_spy_matcher.rb', line 44
def with(*args)
@args = args
self
end
|
#with_a_block ⇒ Object
49
50
51
52
|
# File 'lib/flexmock/rspec_spy_matcher.rb', line 49
def with_a_block
@needs_block = true
self
end
|
#without_a_block ⇒ Object
54
55
56
57
|
# File 'lib/flexmock/rspec_spy_matcher.rb', line 54
def without_a_block
@needs_block = false
self
end
|