Stubbed method not being returned to its original state at the end of a test
-
James Mead
- State changed from new to open
I wonder whether it's significant that it's the
newmethod that is being stubbed. -
James Mead
It doesn't appear to be significant that it's the
newmethod that is being stubbed. The following test fails with a similar error :-unexpected invocation: B.wibble()require 'rubygems' require 'test/unit' require 'mocha' class A def self.wibble; new; end def value; 'a'; end end class B < A; end class TestA < Test::Unit::TestCase def setup A.stubs( :wibble ).returns( 'this is a' ) B.stubs( :wibble ).returns( 'this is b' ) @a = A.wibble @b = B.wibble end def test_value assert_equal 'this is a', @a assert_equal 'this is b', @b end end class TestB < Test::Unit::TestCase def setup @b = B.wibble end def test_value assert_equal 'a', @b.value end end class TestAgain < Test::Unit::TestCase def setup @a = A.wibble end def test_value assert_equal 'a', @a.value end end
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.