[rspec-users] Stub a controllers helper_method in a view template helper spec

David Chelimsky dchelimsky at gmail.com
Mon Mar 21 14:52:48 EDT 2011

On Mar 21, 2011, at 12:52 PM, Kai Schlamp wrote:

>>> Failure/Error: order_link(:name)
>>>     NoMethodError:
>>>       undefined method `fetch_param' for #<#<Class:0xb63d37ac>:
>>> 0xb63be118>
>> That's not the same error message you posted earlier:
>> NoMethodError:
>>       undefined method `sort_direction' for
>> #<RSpec::Core::ExampleGroup::Nested_1
> The "#<#<Class:0xb63d37ac>" error shows up when using
> helper.check_param in the order_link method as you suggested.

That's not what I meant to suggest.

In the spec, the method being spec'd should be invoked through the helper:

  it "does something" do

I did not mean to reference a helper object inside the implementation.

Make sense?

> The
> "#<RSpec::Core::ExampleGroup::Nested_1" shows up with just using
> check_param (without "helper.").
>> This ^^ message tells us that sort_direction is not implemented on the example. The new message (above) tells us that fetch_param is not implemented on the helper object, which means one of two things:
>> 1) fetch_param is not implemented as an instance method in the ApplicationHelper module. This would be just a matter of implementing it.
> It should be. It works when viewing that template in the browser.
>> 2) ApplicationHelper is not included in the helper object. It should be included if the spec file is in spec/helpers. Is it?
> order_link is known and that is a method of ApplicationHelper, so I
> guess it is included.
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users

More information about the rspec-users mailing list