Michael Schuerig
2010-Jun-19 21:19 UTC
[rspec-users] RSpec 2: view example groups don''t load helpers?
I''m in the process of moving an app from Rails 2.3.8 to 3. In the view spec I''m currently migrating, I get the error undefined method `link_to_xyz'' for #<ActionView::Base:0x7f2c4c0e4820> That method is defined in one of my helpers that are loaded in by the app with helpers :all in the ApplicationController. Is this intended behavior to force me to mock/stub all my own helpers? If not, what do I have to do to make the specs aware of helpers? I can call view.extend(MyHelper) just before rendering, but that''s a bit cumbersome if several helpers are involved. I''m using rspec-rails 2.0.0.beta.12 with Rails 3.0.0.beta4. Michael -- Michael Schuerig mailto:michael at schuerig.de http://www.schuerig.de/michael/
David Chelimsky
2010-Jun-19 22:08 UTC
[rspec-users] RSpec 2: view example groups don''t load helpers?
On Jun 19, 2010, at 4:19 PM, Michael Schuerig wrote:> > I''m in the process of moving an app from Rails 2.3.8 to 3. In the view > spec I''m currently migrating, I get the error > > undefined method `link_to_xyz'' for #<ActionView::Base:0x7f2c4c0e4820> > > That method is defined in one of my helpers that are loaded in by the > app with helpers :all in the ApplicationController. > > Is this intended behavior to force me to mock/stub all my own helpers?Not at all.> If not, what do I have to do to make the specs aware of helpers?helper(MyHelper, :my_helper, ''other_helper'')> I can call view.extend(MyHelper) just before rendering, but that''s a bit > cumbersome if several helpers are involved. > I''m using rspec-rails 2.0.0.beta.12 with Rails 3.0.0.beta4.I''ve got a ticket into rails to make this method work with :all, as documented, but until that''s fixed you have to list them all separately. At least you can do it in one statement :) https://rails.lighthouseapp.com/projects/8994/tickets/4775. HTH, David
Michael Schuerig
2010-Jun-19 23:51 UTC
[rspec-users] RSpec 2: view example groups don''t load helpers?
On Sunday 20 June 2010, David Chelimsky wrote:> On Jun 19, 2010, at 4:19 PM, Michael Schuerig wrote:> > If not, what do I have to do to make the specs aware of helpers? > > helper(MyHelper, :my_helper, ''other_helper'')I see. Thanks, that works. Michael -- Michael Schuerig mailto:michael at schuerig.de http://www.schuerig.de/michael/