My ApplicationController provides a method (e.g. sort_direction ) for presentation templates using helper_method :sort_direction . Then I use this method in another method (e.g. sort_link ) of a view helper ( application_helper.rb ).
When testing the sort_link method with RSpec (in application_helper_spec.rb ), I need to drown out the sort_direction , since the test seems to run completely independent of the controllers (and thus its open view templates).
Unfortunately, I could not find out how to drown out this controller's sort_direction method. I always get the "undefined method".
Here is what I have tried so far (inside application_helper_spec.rb ):
helper.stub(:sort_direction) controller.stub(:sort_direction) view.stub(:sort_direction) self.stub(:sort_direction)
Any suggestions how I can drown out this method?
Here is the error I get:
NoMethodError: undefined method `sort_direction' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_1:0xb641434c>
ruby-on-rails stub rspec
Zardoz
source share