Skip to content

Record invocations for stubs with stub_everything = true #6

Merged
merged 1 commit into from Jul 15, 2011
View
8 lib/bourne/mock.rb
@@ -16,6 +16,14 @@ def method_missing(symbol, *arguments, &block)
message = UnexpectedInvocation.new(self, symbol, *arguments).to_s
message << Mockery.instance.mocha_inspect
raise ExpectationError.new(message, caller)
+ else
+ target = if self.respond_to? :mocha
+ self.mocha
+ else
+ mocha
+ end
+ Mockery.instance.invocation(target, symbol, arguments)
+ nil
end
end
end
View
16 test/acceptance/spy_test.rb
@@ -142,3 +142,19 @@ def new_instance
stub
end
end
+
+class StubEverythingSpyTest < Test::Unit::TestCase
+ include AcceptanceTest
+ def setup
+ setup_acceptance_test
+ end
+
+ def teardown
+ teardown_acceptance_test
+ end
+ def test_should_match_invocations_with_no_explicit_stubbing
+ instance = stub_everything
+ instance.surprise!
+ assert_received(instance, :surprise!)
+ end
+end
Something went wrong with that request. Please try again.