Class: Facon::ErrorGenerator
- Inherits:
-
Object
- Object
- Facon::ErrorGenerator
- Defined in:
- lib/motion-facon/error_generator.rb
Overview
A helper class for generating errors for expectation errors on mocks.
Instance Method Summary collapse
-
#initialize(target, name) ⇒ ErrorGenerator
constructor
A new instance of ErrorGenerator.
- #raise_block_failed_error(method, exception_message) ⇒ Object
- #raise_expectation_error(expectation) ⇒ Object
- #raise_unexpected_message_args_error(expectation, *args) ⇒ Object
- #raise_unexpected_message_error(method, *args) ⇒ Object
Constructor Details
#initialize(target, name) ⇒ ErrorGenerator
Returns a new instance of ErrorGenerator.
4 5 6 |
# File 'lib/motion-facon/error_generator.rb', line 4 def initialize(target, name) @target, @name = target, name end |
Instance Method Details
#raise_block_failed_error(method, exception_message) ⇒ Object
22 23 24 25 |
# File 'lib/motion-facon/error_generator.rb', line 22 def raise_block_failed_error(method, ) = "#{target_name} received :#{method} but passed block failed with: #{}" raise(Facon::MockExpectationError, ) end |
#raise_expectation_error(expectation) ⇒ Object
8 9 10 11 |
# File 'lib/motion-facon/error_generator.rb', line 8 def raise_expectation_error(expectation) = "#{target_name} expected :#{expectation.method} with #{format_args(*expectation.argument_expectation)} #{format_count(expectation.expected_received_count)}, but received it #{format_count(expectation.actual_received_count)}" raise(Facon::MockExpectationError, ) end |
#raise_unexpected_message_args_error(expectation, *args) ⇒ Object
17 18 19 20 |
# File 'lib/motion-facon/error_generator.rb', line 17 def (expectation, *args) = "#{target_name} expected :#{expectation.method} with #{format_args(*expectation.argument_expectation)}, but received it with #{format_args(*args)}" raise(Facon::MockExpectationError, ) end |
#raise_unexpected_message_error(method, *args) ⇒ Object
13 14 15 |
# File 'lib/motion-facon/error_generator.rb', line 13 def (method, *args) raise(Facon::MockExpectationError, "#{target_name} received unexpected message :#{method} with #{format_args(*args)}") end |