@private
# File lib/rspec/mocks/error_generator.rb, line 24 def initialize(target, name) @target = target @name = name end
# File lib/rspec/mocks/error_generator.rb, line 181 def self.raise_double_negation_error(wrapped_expression) raise "Isn't life confusing enough? You've already set a " + "negative message expectation and now you are trying to " + "negate it again with `never`. What does an expression like " + "`#{wrapped_expression}.not_to receive(:msg).never` even mean?" end
@private
# File lib/rspec/mocks/error_generator.rb, line 109 def actual_method_call_args_description(count, args) method_call_args_description(args) || if count > 0 && args.length > 0 " with arguments: #{args.inspect.gsub(/\A\[(.+)\]\z/, '(\1)')}" else "" end end
@private
# File lib/rspec/mocks/error_generator.rb, line 139 def describe_expectation(message, expected_received_count, actual_received_count, *args) "have received #{message}#{format_args(*args)} #{count_message(expected_received_count)}" end
@private
# File lib/rspec/mocks/error_generator.rb, line 119 def expected_method_call_args_description(args) method_call_args_description(args) || if args.length > 0 " with arguments: #{format_args(*args)}" else "" end end
@private
# File lib/rspec/mocks/error_generator.rb, line 103 def expected_part_of_expectation_error(expected_received_count, expectation_count_type, argument_list_matcher) "expected: #{count_message(expected_received_count, expectation_count_type)}" + expected_method_call_args_description(argument_list_matcher.expected_args) end
@private
# File lib/rspec/mocks/error_generator.rb, line 129 def method_call_args_description(args) case args.first when ArgumentMatchers::AnyArgsMatcher return " with any arguments" when ArgumentMatchers::NoArgsMatcher return " with no arguments" end end
@private
# File lib/rspec/mocks/error_generator.rb, line 30 def opts @opts ||= {} end
@private
# File lib/rspec/mocks/error_generator.rb, line 149 def raise_block_failed_error(message, detail) __raise "#{intro} received :#{message} but passed block failed with: #{detail}" end
@private
# File lib/rspec/mocks/error_generator.rb, line 61 def raise_expectation_error(message, expected_received_count, argument_list_matcher, actual_received_count, expectation_count_type, *args) expected_part = expected_part_of_expectation_error(expected_received_count, expectation_count_type, argument_list_matcher) received_part = received_part_of_expectation_error(actual_received_count, *args) __raise "(#{intro}).#{message}#{format_args(*args)}\n #{expected_part}\n #{received_part}" end
@private
# File lib/rspec/mocks/error_generator.rb, line 176 def raise_expectation_on_mocked_method(method) __raise "#{intro} expected to have received #{method}, but that " + "method has been mocked instead of stubbed." end
@private
# File lib/rspec/mocks/error_generator.rb, line 170 def raise_expectation_on_unstubbed_method(method) __raise "#{intro} expected to have received #{method}, but that " + "method has not been stubbed." end
@private
# File lib/rspec/mocks/error_generator.rb, line 88 def raise_expired_test_double_error raise ExpiredTestDoubleError, "#{intro} was originally created in one example but has leaked into " + "another example and can no longer be used. rspec-mocks' doubles are " + "designed to only last for one example, and you need to create a new " + "one in each example you wish to use it for." end
@private
# File lib/rspec/mocks/error_generator.rb, line 83 def raise_invalid_arguments_error(verifier) __raise verifier.error_message end
@private
# File lib/rspec/mocks/error_generator.rb, line 154 def raise_missing_block_error(args_to_yield) __raise "#{intro} asked to yield |#{arg_list(*args_to_yield)}| but no block was passed" end
@private
# File lib/rspec/mocks/error_generator.rb, line 47 def raise_missing_default_stub_error(expectation, *args) expected_args = format_args(*expectation.expected_args) actual_args = format_received_args(*args) __raise "#{intro} received #{expectation.message.inspect} with unexpected arguments\n expected: #{expected_args}\n got: #{actual_args}\n Please stub a default value first if message might be received with other args as well. \n" end
@private
# File lib/rspec/mocks/error_generator.rb, line 76 def raise_non_public_error(method_name, visibility) raise NoMethodError, "%s method `%s' called on %s" % [ visibility, method_name, intro ] end
@private
# File lib/rspec/mocks/error_generator.rb, line 164 def raise_only_valid_on_a_partial_double(method) __raise "#{intro} is a pure test double. `#{method}` is only " + "available on a partial double." end
@private
# File lib/rspec/mocks/error_generator.rb, line 144 def raise_out_of_order_error(message) __raise "#{intro} received :#{message} out of order" end
@private
# File lib/rspec/mocks/error_generator.rb, line 54 def raise_similar_message_args_error(expectation, *args_for_multiple_calls) expected_args = format_args(*expectation.expected_args) actual_args = args_for_multiple_calls.collect {|a| format_received_args(*a)}.join(", ") __raise "#{intro} received #{expectation.message.inspect} with unexpected arguments\n expected: #{expected_args}\n got: #{actual_args}" end
@private
# File lib/rspec/mocks/error_generator.rb, line 40 def raise_unexpected_message_args_error(expectation, *args) expected_args = format_args(*expectation.expected_args) actual_args = format_received_args(*args) __raise "#{intro} received #{expectation.message.inspect} with unexpected arguments\n expected: #{expected_args}\n got: #{actual_args}" end
@private
# File lib/rspec/mocks/error_generator.rb, line 35 def raise_unexpected_message_error(message, *args) __raise "#{intro} received unexpected message :#{message}#{arg_message(*args)}" end
@private
# File lib/rspec/mocks/error_generator.rb, line 68 def raise_unimplemented_error(doubled_module, method_name) __raise "%s does not implement: %s" % [ doubled_module.description, method_name ] end
@private
# File lib/rspec/mocks/error_generator.rb, line 159 def raise_wrong_arity_error(args_to_yield, signature) __raise "#{intro} yielded |#{arg_list(*args_to_yield)}| to block with #{signature.description}" end
@private
# File lib/rspec/mocks/error_generator.rb, line 97 def received_part_of_expectation_error(actual_received_count, *args) "received: #{count_message(actual_received_count)}" + actual_method_call_args_description(actual_received_count, args) end
Generated with the Darkfish Rdoc Generator 2.