Class: Spec::Mocks::ErrorGenerator

Class | Spec::Mocks::ErrorGenerator
In: | lib/spec/mocks/error_generator.rb
Parent: | Object

### Methods

new opts raise_block_failed_error raise_expectation_error raise_missing_block_error raise_out_of_order_error raise_unexpected_message_args_error raise_unexpected_message_error raise_wrong_arity_error

### Attributes

opts | [W] |

### Public Class methods

new(target, name)

[Source]

       # File lib/spec/mocks/error_generator.rb, line 6
    6:       def initialize(target, name)
    7:         @target = target
    8:         @name = name
    9:       end

### Public Instance methods

opts()

[Source]

        # File lib/spec/mocks/error_generator.rb, line 11
    11:       def opts
    12:         @opts ||= {}
    13:       end

raise_block_failed_error(sym, detail)

[Source]

        # File lib/spec/mocks/error_generator.rb, line 33
    33:       def raise_block_failed_error(sym, detail)
    34:         __raise "#{intro} received :#{sym} but passed block failed with: #{detail}"
    35:       end

raise_expectation_error(sym, expected_received_count, actual_received_count, *args)

[Source]

        # File lib/spec/mocks/error_generator.rb, line 25
    25:       def raise_expectation_error(sym, expected_received_count, actual_received_count, *args)
    26:         __raise "#{intro} expected :#{sym}#{arg_message(*args)} #{count_message(expected_received_count)}, but received it #{count_message(actual_received_count)}"
    27:       end

raise_missing_block_error(args_to_yield)

[Source]

        # File lib/spec/mocks/error_generator.rb, line 37
    37:       def raise_missing_block_error(args_to_yield)
    38:         __raise "#{intro} asked to yield |#{arg_list(*args_to_yield)}| but no block was passed"
    39:       end

raise_out_of_order_error(sym)

[Source]

        # File lib/spec/mocks/error_generator.rb, line 29
    29:       def raise_out_of_order_error(sym)
    30:         __raise "#{intro} received :#{sym} out of order"
    31:       end

raise_unexpected_message_args_error(expectation, *args)

[Source]

        # File lib/spec/mocks/error_generator.rb, line 19
    19:       def raise_unexpected_message_args_error(expectation, *args)
    20:         expected_args = format_args(*expectation.expected_args)
    21:         actual_args = args.empty? ? "(no args)" : format_args(*args)
    22:         __raise "#{intro} expected #{expectation.sym.inspect} with #{expected_args} but received it with #{actual_args}"
    23:       end

raise_unexpected_message_error(sym, *args)

[Source]

        # File lib/spec/mocks/error_generator.rb, line 15
    15:       def raise_unexpected_message_error(sym, *args)
    16:         __raise "#{intro} received unexpected message :#{sym}#{arg_message(*args)}"
    17:       end

raise_wrong_arity_error(args_to_yield, arity)

[Source]

        # File lib/spec/mocks/error_generator.rb, line 41
    41:       def raise_wrong_arity_error(args_to_yield, arity)
    42:         __raise "#{intro} yielded |#{arg_list(*args_to_yield)}| to block with arity of #{arity}"
    43:       end

[Validate]