Skip to content

Commit

Permalink
Use the improved message from the prev commit for stubs, not message …
Browse files Browse the repository at this point in the history
…expectations.

- Closes #147, #123.
  • Loading branch information
dchelimsky committed Jun 4, 2012
1 parent 1ebc698 commit 49ce496
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 24 deletions.
16 changes: 5 additions & 11 deletions lib/rspec/mocks/proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,7 @@ def message_received(message, *args, &block)
raise_unexpected_message_args_error(expectation, *args) unless (has_negative_expectation?(message) or null_object?)
elsif stub = find_almost_matching_stub(message, *args)
stub.advise(*args)
raise_unexpected_message_args_error(stub, *args)
elsif expectation = find_almost_matching_satisfied_expectation(message,*args)
raise_missing_default_stub_error(expectation, *args) if not null_object?
raise_missing_default_stub_error(stub, *args)
elsif @object.is_a?(Class)
@object.superclass.__send__(message, *args, &block)
else
Expand All @@ -139,13 +137,13 @@ def message_received(message, *args, &block)
end

# @private
def raise_unexpected_message_args_error(expectation, *args)
@error_generator.raise_unexpected_message_args_error(expectation, *args)
def raise_unexpected_message_error(method_name, *args)
@error_generator.raise_unexpected_message_error method_name, *args
end

# @private
def raise_unexpected_message_error(method_name, *args)
@error_generator.raise_unexpected_message_error method_name, *args
def raise_unexpected_message_args_error(expectation, *args)
@error_generator.raise_unexpected_message_args_error(expectation, *args)
end

# @private
Expand All @@ -172,10 +170,6 @@ def find_almost_matching_expectation(method_name, *args)
method_double[method_name].expectations.find {|expectation| expectation.matches_name_but_not_args(method_name, *args) && !expectation.called_max_times?}
end

def find_almost_matching_satisfied_expectation(method_name, *args)
method_double[method_name].expectations.find {|expectation| expectation.matches_name_but_not_args(method_name, *args) }
end

def find_matching_method_stub(method_name, *args)
method_double[method_name].stubs.find {|stub| stub.matches?(method_name, *args)}
end
Expand Down
1 change: 0 additions & 1 deletion lib/rspec/mocks/test_double.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,3 @@ def assign_stubs(stubs)
end
end
end

10 changes: 0 additions & 10 deletions spec/rspec/mocks/bug_report_123_spec.rb

This file was deleted.

4 changes: 2 additions & 2 deletions spec/rspec/mocks/stub_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,10 @@ def existing_private_instance_method
end.should raise_error(/received :foo with unexpected arguments/)
end

it "complains if called with other arg" do
it "complains if called with other arg", :github_issue => [123,147] do
lambda do
@stub.foo("other")
end.should raise_error(/received :foo with unexpected arguments/)
end.should raise_error(/received :foo with unexpected arguments.*Please stub a default value/m)
end

it "does not complain if also mocked w/ different args" do
Expand Down

0 comments on commit 49ce496

Please sign in to comment.