Silumesii Maboshe
2011-Sep-15 09:08 UTC
[rspec-users] Access to asset_path helper in a Rails 3.1 application request spec
Hello! I am learning to use RSpec for testing Rails 3.1 applications - really enjoying using it so far. In testing for the presence of assets (e.g rails.png), I''ve been using: get "/assets/rails.png" response.status.should be(200) After some reading about the Rails 3.1 asset pipeline I discovered the "asset_path" helper. Is it possible to access this helper in a request spec? I have not had any success so far: get asset_path, "rails.png" response.status.should be(200) Gives: undefined local variable or method ''asset_path''. Any help with this would be appreciated. Best, Silumesii -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20110915/958afab2/attachment-0001.html>
Justin Ko
2011-Sep-25 07:35 UTC
[rspec-users] Access to asset_path helper in a Rails 3.1 application request spec
On Sep 15, 2011, at 3:08 AM, Silumesii Maboshe wrote:> Hello! > > I am learning to use RSpec for testing Rails 3.1 applications - really enjoying using it so far. > In testing for the presence of assets (e.g rails.png), I''ve been using: > > get "/assets/rails.png" > response.status.should be(200) > > After some reading about the Rails 3.1 asset pipeline I discovered the "asset_path" helper. Is it possible to access this helper in a request spec? I have not had any success so far: > > get asset_path, "rails.png" > response.status.should be(200) > > Gives: > > undefined local variable or method ''asset_path''. > > Any help with this would be appreciated. > > Best, > > Silumesii > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users"asset_path" isn''t a routing URL helper, it''s a Sprocket helper. Try this: # in spec_helper.rb config.include Sprockets::Helpers::RailsHelper, :type => :request