[rspec-users] Stub a controllers helper_method in a view template helper spec
dchelimsky at gmail.com
Mon Mar 21 10:08:47 EDT 2011
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
> Here is how check_param is called from within the helper:
> module ApplicationHelper
> def order_link(column, title = nil)
Change this ^^ to this:
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.
> and in application controller:
> helper_method :fetch_param
> def fetch_param(name)
> rspec-users mailing list
> rspec-users at rubyforge.org
More information about the rspec-users