Is there an easy way to spec that a controller should include helpers other than its own? I was thinking I could just spec responds_to for methods I''m interested in in the view, but that seems like crossing a separation boundary, that the controller maybe doesn''t need to know about? Thanks, Steve
David Chelimsky
2007-Nov-03 06:00 UTC
[rspec-users] Test that controller includes helpers?
On Nov 2, 2007 5:59 PM, Steve <vertebrate at gmail.com> wrote:> Is there an easy way to spec that a controller should include helpers > other than its own? I was thinking I could just spec responds_to for > methods I''m interested in in the view, but that seems like crossing a > separation boundary, that the controller maybe doesn''t need to know about?FWIW, by asking you to declare helpers in controllers so that views can access their goodness, Rails is already forcing you to cross that boundary. So whatever you do here is a compromise and you just need to find the lesser of evils. I think the most pragmatic thing to do would be to use a controller spec with integrate_views and describe what the view should look like when it uses one of the included methods. Alternatively could load the file and expect the declaration (but that''s somewhat controversial on this list). HTH, David
On Sat, 03 Nov 2007 02:00:56 -0400, David Chelimsky wrote:> FWIW, by asking you to declare helpers in controllers so that views > can access their goodness, Rails is already forcing you to cross that > boundary. So whatever you do here is a compromise and you just need to > find the lesser of evils. > > I think the most pragmatic thing to do would be to use a controller > spec with integrate_views and describe what the view should look like > when it uses one of the included methods. Alternatively could load the > file and expect the declaration (but that''s somewhat controversial on > this list). > > HTH, > DavidYeah, I''m not terribly interested in the reloading of the file. That was too much of a pain last time with my models and I opted not to do it. I''d rather not integrate the view if I can avoid it. Is there a way to get at the controller instance that was called though? If I could do that, I could simply check for a responds_to at the very least, right? I understand what you mean by blurring the lines though. Steve