Class: ShellMock::CallVerifier
- Inherits:
-
Object
- Object
- ShellMock::CallVerifier
- Defined in:
- lib/shell_mock/call_verifier.rb
Instance Method Summary collapse
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
- #fewer_than(n) ⇒ Object (also: #less_than)
-
#initialize ⇒ CallVerifier
constructor
A new instance of CallVerifier.
- #matches?(actual) ⇒ Boolean
- #more_than(n) ⇒ Object
- #never ⇒ Object
- #once ⇒ Object
- #times(n) ⇒ Object
Constructor Details
#initialize ⇒ CallVerifier
Returns a new instance of CallVerifier.
3 4 5 |
# File 'lib/shell_mock/call_verifier.rb', line 3 def initialize match_calls_when { |calls| calls.any? } end |
Instance Method Details
#failure_message ⇒ Object
13 14 15 |
# File 'lib/shell_mock/call_verifier.rb', line 13 def "#{actual.command} was expected." end |
#failure_message_when_negated ⇒ Object
17 18 19 |
# File 'lib/shell_mock/call_verifier.rb', line 17 def "#{actual.command} was not expected." end |
#fewer_than(n) ⇒ Object Also known as: less_than
35 36 37 38 39 |
# File 'lib/shell_mock/call_verifier.rb', line 35 def fewer_than(n) match_calls_when { |calls| calls.size < n } self end |
#matches?(actual) ⇒ Boolean
7 8 9 10 11 |
# File 'lib/shell_mock/call_verifier.rb', line 7 def matches?(actual) @actual = actual condition.call(actual.calls) end |
#more_than(n) ⇒ Object
42 43 44 45 46 |
# File 'lib/shell_mock/call_verifier.rb', line 42 def more_than(n) match_calls_when { |calls| calls.size > n } self end |
#never ⇒ Object
25 26 27 |
# File 'lib/shell_mock/call_verifier.rb', line 25 def never times(0) end |
#once ⇒ Object
21 22 23 |
# File 'lib/shell_mock/call_verifier.rb', line 21 def once times(1) end |
#times(n) ⇒ Object
29 30 31 32 33 |
# File 'lib/shell_mock/call_verifier.rb', line 29 def times(n) match_calls_when { |calls| calls.size == n } self end |