[rspec-users] [TDD] [Rails] - Rspec test for application_helper.rb fails when trying to access application_controller method.
jrbruce at gmail.com
Mon Nov 29 17:37:06 EST 2010
In a method named logo in my application helper, I reference an application controller method (current_account) that has been marked as a helper method with the following syntax:
When I test out the setup in the browser (without rspec), rails is happy with this setup.
However, when I run the spec, the spec won't pass and gives me the following error:
1) ApplicationHelper#logo image tag should point to logo.png
Failure/Error: helper.logo.should =~ /logo.png/i
undefined local variable or method `current_account' for #<ActionView::Base:0x105645108>
# ./app/helpers/application_helper.rb:13:in `logo'
Rspec Version 2.1.0
Rails Version 3.0.1
I've created a gist that shows how my code is setup, and how the helper is calling the controller method:
Does anyone know why this setup works fine outside of rspec (when I test in the browser), but won't work within rspec?
Is there an object / instance variable that I need to mock, or a setting that I need to change in order for the helper spec to know about the controller methods that have been marked as helper methods?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the rspec-users