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
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to