This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Record invocations for stubs with stub_everything = true

  • Loading branch information...
1 parent 5640e51 commit a4149be5b4d08a38a034e55d389d86ad4b05dc44 @opsb opsb committed Nov 6, 2010
Showing with 24 additions and 0 deletions.
  1. +8 −0 lib/bourne/mock.rb
  2. +16 −0 test/acceptance/spy_test.rb
View
@@ -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
@@ -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

0 comments on commit a4149be

Please sign in to comment.