[rspec-users] my helper stubs aren't working (rspec2, rails3)

Kevin Lochner lists at ruby-forum.com
Sat Jan 1 16:10:55 EST 2011


Kevin Lochner wrote in post #971805:
> David Chelimsky wrote in post #971793:
>

> Unfortunately that worked:
>
>    ThingsHelper
>      supports stubs
>
> . . . so there's something weird going on with my app.

It seems that I left out a critical detail :)

I was using incorrect syntax to stub a different method in a before
block:

  before do
    stub(:some_other_method).and_return(val)
  end

Which appears to silently break stubbing.  Try the following:

  describe ThingsHelper do
    it "supports stubs" do
      stub!(:bar) {"foobar"}
      helper.stub(:foo) { "bar" }
      helper.foo.should eq("bar")
    end
  end


that gives me:

  1) ThingsHelper supports stubs
     Failure/Error: helper.foo.should eq("bar")
     undefined method `foo' for #<ActionView::Base:0x1cef47c>

-- 
Posted via http://www.ruby-forum.com/.


More information about the rspec-users mailing list