[rspec-devel] [ rspec-Bugs-12603 ] Methods in controllers defined with helper_method are not available in helper tests

noreply at rubyforge.org noreply at rubyforge.org
Thu Jul 26 15:32:41 EDT 2007


Bugs item #12603, was opened at 2007-07-26 17:56
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3149&aid=12603&group_id=797

Category: rails plugin
Group: None
Status: Open
Resolution: None
Priority: 3
Submitted By: Michael Schreifels (technel)
Assigned to: Nobody (None)
Summary: Methods in controllers defined with helper_method are not available in helper tests

Initial Comment:
When you define a method in a controller and use helper_method to make it available in views and helpers, it is not made available to Rspec helper tests.

----------------------------------------------------------------------

>Comment By: Michael Schreifels (technel)
Date: 2007-07-26 19:32

Message:
Hi David,

I didn't actually clarify exactly what I was trying to do,
but the solution would remain the same (that is, to include
helpers defined using helper_method in controllers).

This issue came up when I had a method in
helpers/application_helper.rb that would check the value of
the logged_in? method and return a URL to the index page
based on that (e.g. user dashboard vs index page for
non-registered users). I decided to test this (regular)
helper method with a spec. The problem was that I kept
getting NoMethodError for logged_in? because it was a helper
method defined in the controller and thus was not included.

I ended up just stubbing out logged_in? and it wasn't a
problem, but I just wanted to bring it to your attention.


Mike

----------------------------------------------------------------------

Comment By: David Chelimsky (dchelimsky)
Date: 2007-07-26 18:39

Message:
Here's my instinctive reaction to this:

Helper examples are where you describe methods in your helper modules, not helper methods defined anywhere else (like in a controller). If you're defining this method in your controller, then you should be describing it in a controller example.

Based on that, I'm inclined to reject this. But I'll leave it open for the moment and await your comments on this thinking.

Thanks,
David

----------------------------------------------------------------------

You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3149&aid=12603&group_id=797


More information about the rspec-devel mailing list