Hey guys. One of my models uses a Rails URL helper. In IRB, the method works. However, when I run the specs for the method, the URL helper doesn''t exist. The only solution I''ve found is to include Rails.application.routes.url_helpers in both the model and the example group. Obviously, that''s not ideal, because it''s only necessary for the specs to work. Is there any other solution? https://gist.github.com/1275799 Thanks, Nick -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20111010/d64e3c5b/attachment-0001.html>
On 10 Oct 2011, at 18:02, Nick wrote:> Hey guys. One of my models uses a Rails URL helper. In IRB, the method works. However, when I run the specs for the method, the URL helper doesn''t exist. > > The only solution I''ve found is to include Rails.application.routes.url_helpers in both the model and the example group. Obviously, that''s not ideal, because it''s only necessary for the specs to work. Is there any other solution? > > https://gist.github.com/1275799I don''t know about anyone else, but I can''t see that gist. cheers, Matt -- Freelance programmer & coach Author, http://pragprog.com/book/hwcuc/the-cucumber-book (with Aslak Helles?y) Founder, http://relishapp.com +44(0)7974430184 | http://twitter.com/mattwynne
Hey Matt. Thanks for replying. I deleted that gist by accident earlier today. Despite that, the problem''s solved by including Rails.application.routes.url_helpers in my model. My Rails console sessions include Rails.application.routes.url_helpers automatically, which is why it worked in IRB but not when run with RSpec. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20111011/1356e109/attachment.html>