# File lib/spec/mocks/error_generator.rb, line 12
12: def opts
13: @opts ||= {}
14: end
# File lib/spec/mocks/error_generator.rb, line 34
34: def raise_block_failed_error(sym, detail)
35: __raise "#{intro} received :#{sym} but passed block failed with: #{detail}"
36: end
# File lib/spec/mocks/error_generator.rb, line 26
26: def raise_expectation_error(sym, expected_received_count, actual_received_count, *args)
27: __raise "#{intro} expected :#{sym}#{arg_message(*args)} #{count_message(expected_received_count)}, but received it #{count_message(actual_received_count)}"
28: end
# File lib/spec/mocks/error_generator.rb, line 38
38: def raise_missing_block_error(args_to_yield)
39: __raise "#{intro} asked to yield |#{arg_list(*args_to_yield)}| but no block was passed"
40: end
# File lib/spec/mocks/error_generator.rb, line 30
30: def raise_out_of_order_error(sym)
31: __raise "#{intro} received :#{sym} out of order"
32: end
# File lib/spec/mocks/error_generator.rb, line 20
20: def raise_unexpected_message_args_error(expectation, *args)
21: expected_args = format_args(*expectation.expected_args)
22: actual_args = args.empty? ? "(no args)" : format_args(*args)
23: __raise "#{intro} received #{expectation.sym.inspect} with unexpected arguments\n expected: #{expected_args}\n got: #{actual_args}"
24: end
# File lib/spec/mocks/error_generator.rb, line 62
62: def __raise(message)
63: message = opts[:message] unless opts[:message].nil?
64: Kernel::raise(Spec::Mocks::MockExpectationError, message)
65: end
# File lib/spec/mocks/error_generator.rb, line 75
75: def arg_list(*args)
76: args.collect {|arg| arg.respond_to?(:description) ? arg.description : arg.inspect}.join(", ")
77: end
# File lib/spec/mocks/error_generator.rb, line 67
67: def arg_message(*args)
68: " with " + format_args(*args)
69: end
# File lib/spec/mocks/error_generator.rb, line 79
79: def count_message(count)
80: return "at least #{pretty_print(count.abs)}" if count < 0
81: return pretty_print(count)
82: end
# File lib/spec/mocks/error_generator.rb, line 71
71: def format_args(*args)
72: args.empty? ? "(no args)" : "(" + arg_list(*args) + ")"
73: end
# File lib/spec/mocks/error_generator.rb, line 48
48: def intro
49: if @name
50: "#{@declared_as} #{@name.inspect}"
51: elsif Mock === @target
52: @declared_as
53: elsif Class === @target
54: "<#{@target.inspect} (class)>"
55: elsif @target
56: @target
57: else
58: "nil"
59: end
60: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.