Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #11 from tristandunn/unstubbed-expectation

Mention when a method with an expectation is unstubbed. Fixes #5.
  • Loading branch information...
commit b29c1cdde80c262529557ee7c841aa736a8f34f7 2 parents 650afb0 + 17dc7d2
Gabe Berke-Williams gabebw authored
Showing with 15 additions and 1 deletion.
  1. +9 −1 lib/bourne/api.rb
  2. +6 −0 test/acceptance/spy_test.rb
10 lib/bourne/api.rb
View
@@ -51,7 +51,9 @@ def does_not_match?(mock)
end
def failure_message
- @expectation.mocha_inspect
+ message = ""
+ message << "unstubbed, " if matching_stubs.length == 0
+ message << @expectation.mocha_inspect
end
private
@@ -71,6 +73,12 @@ def invocations
invocation.mock.equal?(@mock)
end
end
+
+ def matching_stubs
+ Mockery.instance.stubba.stubba_methods.select do |method|
+ method.mock.equal?(@mock) && method.method == @expected_method_name
+ end
+ end
end
# :call-seq:
6 test/acceptance/spy_test.rb
View
@@ -95,6 +95,12 @@ def test_should_not_allow_should_not
flunk("Expected to fail")
end
+ def test_should_warn_for_unstubbed_methods_with_expectations
+ new_instance.stubs(:unknown)
+
+ assert_fails(/unstubbed, expected exactly once/) { assert_matcher_accepts have_received(:unknown), new_instance }
+ end
+
def test_should_reject_not_enough_calls
instance = new_instance
instance.stubs(:magic)
Please sign in to comment.
Something went wrong with that request. Please try again.