I'm having trouble using stubs to intercept method calls in the object
constructor. Here's some code with a failing example:
class Test2
attr_accessor :msg
def initialize
@msg = sayhi
end
def sayhi
"hi"
end
end
describe Test2, "stubbing methods used during object construction" do
it "should assign the stub value to the instance variable" do
Test2.stub!(:sayhi).and_return("bye")
Test2.new.msg.should == "bye"
end
end
(full test-case at https://gist.github.com/878911)
What should I do to make this work?!?
Thanks, Andy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20110320/434e56b3/attachment-0001.html>