diff --git a/lib/rspec/mocks/error_generator.rb b/lib/rspec/mocks/error_generator.rb index 9f3a4b01b..7037b438f 100644 --- a/lib/rspec/mocks/error_generator.rb +++ b/lib/rspec/mocks/error_generator.rb @@ -261,6 +261,17 @@ def unexpected_arguments_message(expected_args_string, actual_args_string) def error_message(expectation, args_for_multiple_calls) expected_args = format_args(expectation.expected_args) actual_args = format_received_args(args_for_multiple_calls) + + if RSpec::Support::RubyFeatures.distincts_kw_args_from_positional_hash? && expected_args == actual_args + expected_hash = expectation.expected_args.last + actual_hash = args_for_multiple_calls.last.last + if Hash === expected_hash && Hash === actual_hash && + (Hash.ruby2_keywords_hash?(expected_hash) != Hash.ruby2_keywords_hash?(actual_hash)) + actual_args += Hash.ruby2_keywords_hash?(actual_hash) ? " (keyword arguments)" : " (options hash)" + expected_args += Hash.ruby2_keywords_hash?(expected_hash) ? " (keyword arguments)" : " (options hash)" + end + end + message = default_error_message(expectation, expected_args, actual_args) if args_for_multiple_calls.one?