testdouble / jasmine-rails

A Jasmine runner for rails projects that's got you covered in both the terminal and the browser
http://rubygems.org/gems/jasmine-rails
MIT License
378 stars 154 forks source link

assets.raise_runtime_errors can't be set when running the tests #147

Closed seanlinsley closed 8 years ago

seanlinsley commented 9 years ago

With this setting in development.rb:

config.assets.raise_runtime_errors = true

Running rake spec:javascript fails with this error:

Sprockets::Rails::Helper::AbsoluteAssetPathError - Asset names passed to helpers should not include the "/assets/" prefix. Instead of "/assets/jasmine.css", use "jasmine.css":
  sprockets-rails (2.2.0) lib/sprockets/rails/helper.rb:200:in `check_errors_for'
  sprockets-rails (2.2.0) lib/sprockets/rails/helper.rb:89:in `asset_path'
  actionview (4.1.6) lib/action_view/helpers/asset_url_helper.rb:256:in `stylesheet_path'
  actionview (4.1.6) lib/action_view/helpers/asset_tag_helper.rb:100:in `block in stylesheet_link_tag'
  actionview (4.1.6) lib/action_view/helpers/asset_tag_helper.rb:96:in `stylesheet_link_tag'
  sprockets-rails (2.2.0) lib/sprockets/rails/helper.rb:162:in `block (2 levels) in stylesheet_link_tag'
  sprockets-rails (2.2.0) lib/sprockets/rails/helper.rb:161:in `block in stylesheet_link_tag'
  sprockets-rails (2.2.0) lib/sprockets/rails/helper.rb:158:in `stylesheet_link_tag'
  jasmine-rails (0.10.2) app/views/layouts/jasmine_rails/spec_runner.html.erb:7
  actionview (4.1.6) lib/action_view/template.rb:145:in `block in render'
  activesupport (4.1.6) lib/active_support/notifications.rb:161:in `instrument'
  actionview (4.1.6) lib/action_view/template.rb:339:in `instrument'
  actionview (4.1.6) lib/action_view/template.rb:143:in `render'
  rack-mini-profiler (0.9.2) lib/mini_profiler/profiling_methods.rb:108:in `block in profile_method'

It looks like check_errors_for is being run twice, once on jasmine.css (which succeeds), then later on /assets/jasmine.css (which fails). This might be a bug in Sprockets; I'm not sure.

This is only really an issue because the test suite is unexpectedly running in the development environment: #121

Note that this bug doesn't occur if I run the tests directly from my browser.

searls commented 9 years ago

Thanks for filing. I don't have much time to actively maintain jasmine-rails but a PR would be very welcome

searls commented 9 years ago

Took me a long time to find this, but I can confirm this issue still exists on master.

searls commented 8 years ago

@seanlinsley safe to close now that #173 is landed?

seanlinsley commented 8 years ago

I just confirmed that this has been resolved. Thanks @rudyjahchan and @searls :green_heart: