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

David Chelimsky dchelimsky at gmail.com
Fri Dec 31 19:36:30 EST 2010


On Dec 31, 2010, at 1:48 PM, Kevin Lochner wrote:

> My helper tests broke when I upgraded to rails3/rspec2.  I don't seem to
> be able to stub out methods in my helper tests.
> 
> Anyone know what's going on here?
> 
> #users_helper_spec.rb
> describe UsersHelper do
>  describe "the helper" do
>    it "should stub" do
>      helper.stub(:foobar_method).and_return(666)
>      helper.foobar_method.should == 666
>    end
>  end
> end
> 
> gives me:
> 
> 1) UsersHelper the helper should stub
>  Failure/Error: helper.foobar_method.should == 666
>  undefined method `foobar_method' for #<ActionView::Base:0x4808014>
>  # ./spec/helpers/users_helper_spec.rb:5

I copied that code into a new Rails 3/RSpec 2 app and the example passes without error.

Can you post your Gemfile and spec/spec_helper.rb files? I'm guessing there's a configuration problem of some sort.

Cheers,
David


More information about the rspec-users mailing list