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: 

helper_method :current_account

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:

Failures:
  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'
     # ./spec/helpers/application_helper_spec.rb:21

Current Versions:
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:

https://gist.github.com/720757

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?

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

Reply via email to