On Mar 21, 2011, at 8:40 AM, Kai Schlamp wrote:

>> This error ^^ suggests that sort_direction is being called on the example 
>> itself rather than the helper object. Please post the spec so we can see 
>> what's going on.
> 
> Sure ...
> 
> describe ApplicationHelper do
>  describe "order link" do
>    it "should create html link" do
>      # things I tried
>      view.stub(:check_param)
>      helper.stub(:check_param)
>      controller.stub(:check_param)
>      self.stub(:check_param)
> 
>      order_link(:name)
>    end
>  end
> end
> 
> Here is how check_param is called from within the helper:
> 
> module ApplicationHelper
>  def order_link(column, title = nil)
>    fetch_param(:order)

Change this ^^ to this:

  helper.fetch_param(:order)

The problem is that ActionView::TestCase::Behavior, which helper specs rely on, 
include the module being spec'd right in the spec, so you have access to those 
methods directly.

RSpec expresses an opinion that the object should be wrapped instead by 
providing a helper object that includes the module being spec'd, but does not 
remove the module methods from the scope of the spec.

HTH,
David

>  end
> end
> 
> and in application controller:
> 
> ...
> helper_method :fetch_param
> 
> def fetch_param(name)
>  ...
> end
> ...
> 
> _______________________________________________
> rspec-users mailing list
> rspec-users@rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users

_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to