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

Issues with Rails 5 #185

Closed mikemerritt closed 8 years ago

mikemerritt commented 8 years ago

I'm attempting to test React components in Rails but there seem to be some issues with jasmine-rails and Rails 5.0. Running rake spec:javascripts --trace returns the following error.

** Invoke spec:javascripts (first_time)
** Invoke spec:javascript (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute spec:javascript
DEPRECATION WARNING: alias_method_chain is deprecated. Please, use Module#prepend instead. From module, you can access the original method using super. (called from mon_synchronize at /Users/mike/.rbenv/versions/2.3.0/lib/ruby/2.3.0/monitor.rb:214)
rake aborted!
NameError: undefined method `compute_public_path' for module `Sprockets::Rails::Helper'

I put together an example application here: https://github.com/mikemerritt/rails5-react-jasmine

I've tried downgrading to older sprockets versions with no luck.

mikemerritt commented 8 years ago

After further digging it appears to be caused by this line. https://github.com/searls/jasmine-rails/blob/master/lib/jasmine_rails/offline_asset_paths.rb#L10

Changing it to if ::Rails::VERSION::MAJOR >= 4 allows my tests to run but also generates a whole slew of depreciation warnings. A workaround but hardly a proper solution.

DEPRECATION WARNING: alias_method_chain is deprecated. Please, use Module#prepend instead. From module, you can access the original method using super. (called from block in <module:OfflineAssetPaths> at /Users/mike/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/bundler/gems/jasmine-rails-a0968df653eb/lib/jasmine_rails/offline_asset_paths.rb:13)
DEPRECATION WARNING: alias_method_chain is deprecated. Please, use Module#prepend instead. From module, you can access the original method using super. (called from block in <module:OfflineAssetPaths> at /Users/mike/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/bundler/gems/jasmine-rails-a0968df653eb/lib/jasmine_rails/offline_asset_paths.rb:16)
DEPRECATION WARNING: ActionDispatch::IntegrationTest HTTP request methods will accept only
the following keyword arguments in future Rails versions:
params, headers, env, xhr

Examples:

get '/profile',
  params: { id: 1 },
  headers: { 'X-Extra-Header' => '123' },
  env: { 'action_dispatch.custom' => 'custom' },
  xhr: true
. (called from get_spec_runner at /Users/mike/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/bundler/gems/jasmine-rails-a0968df653eb/lib/jasmine_rails/runner.rb:61)
Running `"phantomjs" "" "/Users/mike/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/bundler/gems/jasmine-rails-a0968df653eb/lib/jasmine_rails/../assets/javascripts/jasmine-runner.js" "file:///Users/mike/Code/xxxxxx/xxxxxx/tmp/jasmine/runner.html?spec="`
Running: file:///Users/mike/Code/xxxxxx/xxxxxx/tmp/jasmine/runner.html?spec=
Starting...

Finished
-----------------
0 specs, 0 failures in 0.001s.

ConsoleReporter finished
xuwupeng2000 commented 8 years ago

Same issue here - Rails 5

zjeraar commented 8 years ago

Same here with Rails 5.0.0.beta3

3den commented 8 years ago

same problem here too

searls commented 8 years ago

Thanks for this thread. I'm not ignoring you, I've just been putting off this issue for too long, which is particularly problematic as Rails 5's release is certainly imminent.

searls commented 8 years ago

Now that Rails 5 works, I need help clearing the deprecation warnings. I spent a few hours yesterday reworking jasmine-rails build to execute all the supported versions of rails while adding rails 5. That means there should be enough of a harness in place for someone to take a stab at clearing the deprecation warnings without breaking too much.

Let's track this in #187 from here on