Class: Spec::Mocks::ErrorGenerator
- Defined in:
- lib/gems/rspec-1.1.12/lib/spec/mocks/error_generator.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#initialize(target, name) ⇒ ErrorGenerator
constructor
A new instance of ErrorGenerator.
- #raise_block_failed_error(sym, detail) ⇒ Object
- #raise_expectation_error(sym, expected_received_count, actual_received_count, *args) ⇒ Object
- #raise_missing_block_error(args_to_yield) ⇒ Object
- #raise_out_of_order_error(sym) ⇒ Object
- #raise_unexpected_message_args_error(expectation, *args) ⇒ Object
- #raise_unexpected_message_error(sym, *args) ⇒ Object
- #raise_wrong_arity_error(args_to_yield, arity) ⇒ Object
Constructor Details
#initialize(target, name) ⇒ ErrorGenerator
Returns a new instance of ErrorGenerator.
6 7 8 9 |
# File 'lib/gems/rspec-1.1.12/lib/spec/mocks/error_generator.rb', line 6 def initialize(target, name) @target = target @name = name end |
Instance Attribute Details
#opts ⇒ Object
11 12 13 |
# File 'lib/gems/rspec-1.1.12/lib/spec/mocks/error_generator.rb', line 11 def opts @opts ||= {} end |
Instance Method Details
#raise_block_failed_error(sym, detail) ⇒ Object
33 34 35 |
# File 'lib/gems/rspec-1.1.12/lib/spec/mocks/error_generator.rb', line 33 def raise_block_failed_error(sym, detail) __raise "#{intro} received :#{sym} but passed block failed with: #{detail}" end |
#raise_expectation_error(sym, expected_received_count, actual_received_count, *args) ⇒ Object
25 26 27 |
# File 'lib/gems/rspec-1.1.12/lib/spec/mocks/error_generator.rb', line 25 def raise_expectation_error(sym, expected_received_count, actual_received_count, *args) __raise "#{intro} expected :#{sym}#{(*args)} #{(expected_received_count)}, but received it #{(actual_received_count)}" end |
#raise_missing_block_error(args_to_yield) ⇒ Object
37 38 39 |
# File 'lib/gems/rspec-1.1.12/lib/spec/mocks/error_generator.rb', line 37 def raise_missing_block_error(args_to_yield) __raise "#{intro} asked to yield |#{arg_list(*args_to_yield)}| but no block was passed" end |
#raise_out_of_order_error(sym) ⇒ Object
29 30 31 |
# File 'lib/gems/rspec-1.1.12/lib/spec/mocks/error_generator.rb', line 29 def raise_out_of_order_error(sym) __raise "#{intro} received :#{sym} out of order" end |
#raise_unexpected_message_args_error(expectation, *args) ⇒ Object
19 20 21 22 23 |
# File 'lib/gems/rspec-1.1.12/lib/spec/mocks/error_generator.rb', line 19 def (expectation, *args) expected_args = format_args(*expectation.expected_args) actual_args = args.empty? ? "(no args)" : format_args(*args) __raise "#{intro} expected #{expectation.sym.inspect} with #{expected_args} but received it with #{actual_args}" end |
#raise_unexpected_message_error(sym, *args) ⇒ Object
15 16 17 |
# File 'lib/gems/rspec-1.1.12/lib/spec/mocks/error_generator.rb', line 15 def (sym, *args) __raise "#{intro} received unexpected message :#{sym}#{(*args)}" end |
#raise_wrong_arity_error(args_to_yield, arity) ⇒ Object
41 42 43 |
# File 'lib/gems/rspec-1.1.12/lib/spec/mocks/error_generator.rb', line 41 def raise_wrong_arity_error(args_to_yield, arity) __raise "#{intro} yielded |#{arg_list(*args_to_yield)}| to block with arity of #{arity}" end |