Class: RSpec::Bash::Mocks::ScriptMessageExpectation
- Inherits:
-
Object
- Object
- RSpec::Bash::Mocks::ScriptMessageExpectation
- Defined in:
- lib/rspec/bash/mocks/script_message_expectation.rb
Instance Attribute Summary collapse
-
#expected_args ⇒ Object
readonly
Returns the value of attribute expected_args.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
Instance Method Summary collapse
- #called_max_times? ⇒ Boolean
-
#initialize(double:, display_name:, error_generator:, backtrace_line: nil) ⇒ ScriptMessageExpectation
constructor
A new instance of ScriptMessageExpectation.
- #invoke ⇒ Object
- #matches? ⇒ Boolean
- #unadvise ⇒ Object
- #verify_messages_received(script) ⇒ Object
Constructor Details
permalink #initialize(double:, display_name:, error_generator:, backtrace_line: nil) ⇒ ScriptMessageExpectation
Returns a new instance of ScriptMessageExpectation.
11 12 13 14 15 16 17 18 |
# File 'lib/rspec/bash/mocks/script_message_expectation.rb', line 11 def initialize(double:, display_name:, error_generator:, backtrace_line: nil) @double = double @display_name = display_name @error_generator = error_generator @backtrace_line = backtrace_line @expected_args = double.expected_calls @message = @display_name end |
Instance Attribute Details
permalink #expected_args ⇒ Object (readonly)
Returns the value of attribute expected_args.
9 10 11 |
# File 'lib/rspec/bash/mocks/script_message_expectation.rb', line 9 def expected_args @expected_args end |
permalink #message ⇒ Object (readonly)
Returns the value of attribute message.
9 10 11 |
# File 'lib/rspec/bash/mocks/script_message_expectation.rb', line 9 def @message end |
Instance Method Details
permalink #called_max_times? ⇒ Boolean
26 27 28 |
# File 'lib/rspec/bash/mocks/script_message_expectation.rb', line 26 def called_max_times?(*) false end |
permalink #invoke ⇒ Object
[View source]
20 21 |
# File 'lib/rspec/bash/mocks/script_message_expectation.rb', line 20 def invoke(*) end |
permalink #matches? ⇒ Boolean
23 24 |
# File 'lib/rspec/bash/mocks/script_message_expectation.rb', line 23 def matches?(*) end |
permalink #unadvise ⇒ Object
[View source]
73 74 |
# File 'lib/rspec/bash/mocks/script_message_expectation.rb', line 73 def unadvise(*) end |
permalink #verify_messages_received(script) ⇒ Object
[View source]
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/rspec/bash/mocks/script_message_expectation.rb', line 30 def (script) type, expected_count = *@double.expected_call_count actual_count = @double.call_count(script) report = lambda { @error_generator.raise_expectation_error( @display_name, expected_count, ::RSpec::Mocks::ArgumentListMatcher::MATCH_ALL, actual_count, nil, Array(@double.to_s), @backtrace_line ) } case type when :at_least report[] if actual_count < expected_count when :at_most report[] if actual_count > expected_count when :exactly report[] if actual_count != expected_count else fail "Unrecognized call-count quantifier \"#{type}\"" end @double.call_args(script).tap do |actual_args| @double.expected_calls.each_with_index do |args, index| expected = args actual = actual_args[index] if actual != expected @error_generator.( self, actual_args.map { |x| Array(x) }, ) break end end end end |