Rspec-rails: before_filter/after_filter deprecation warning

Created on 25 Feb 2016  路  19Comments  路  Source: rspec/rspec-rails

I tested to make sure this still occurs on the master branch, here are the deprecation warnings I'm seeing:

DEPRECATION WARNING: before_filter is deprecated and will be removed in Rails 5.1. Use before_action instead. (called from <module:HelperExampleGroup> at /Users/connor/.rvm/gems/ruby-2.3.0/bundler/gems/rspec-rails-41628f82e70a/lib/rspec/rails/example/helper_example_group.rb:10)
DEPRECATION WARNING: after_filter is deprecated and will be removed in Rails 5.1. Use after_action instead. (called from <module:HelperExampleGroup> at /Users/connor/.rvm/gems/ruby-2.3.0/bundler/gems/rspec-rails-41628f82e70a/lib/rspec/rails/example/helper_example_group.rb:10)

rails 5.0.0.beta3, rspec-rails & co. on their respective master branches.

*_filter should be replaced by *_action, I believe.

Most helpful comment

@daya : turbolinks 5.0.0.beta2 is already available. You might want to test your app against that version with:

gem 'turbolinks', '~> 5.x'

All 19 comments

The line referenced is the inclusion of ActionView::TestCase::Behaviour so this might be a no op for us at the moment (e.g. it's coming from rails directly and we need to wait for them to fix it).

@JonRowe can you open an issue in Rails, or should I? I'm not entirely sure I understand where that file would be.

See if you can replicate this out side of RSpec by including that module into an empty class, if you can you can use that to demonstrate the issue to Rails

Just confirming that I'm also seeing this. Every time I run tests I get that depreciation warning.

Can you see if you can replicate this outside of RSpec by including ActionView::TestCase::Behaviour into an empty class somewhere? We don't use those methods so they're coming from Rails internally somewhere.

Sorry, mine was being caused by another gem. Updating to the latest version of Rails 5 beta on master showed which gem it was coming from.

@gregblass we can close this right?

For my case it was definitely not coming from rspec-rails. Not sure if this was the same case for the person that opened this. I'd bet it was.

I vote to close, as I would assume based on @gregblass's comments it's not an Rspec issue.

My code keeps yelling at me that it's this line,

require 'rspec/rails'

screen shot 2016-04-24 at 7 24 14 am

Just normal beta stuff, but thought I'd post this up.

I just grepped. As far as I can tell RSpec rails does not use before_filter or after_filter anywhere:

(master)$ git grep -i "before_filter"
(master)$ git grep -i "after_filter"
(master)$

We don't, this is most likely a 3rd party gem as above...

So weird. I wonder why it's saying the require 'rspec/rails' line is the problem line?

Backtrace filtering

@JonRowe which gem is this?

_shrug_ I'd check any which integrate with rails, grep through your gem folder for before_filter or after_filter

lucky me

ack before_filter /Users/dayas/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/

shows

/Users/dayas/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/turbolinks-2.5.3/lib/turbolinks.rb
14:          before_filter :set_xhr_redirected_to, :set_request_method_cookie

and removing turbolinks gem removes the deprecation warnings

@daya : turbolinks 5.0.0.beta2 is already available. You might want to test your app against that version with:

gem 'turbolinks', '~> 5.x'

Upgrading turbolinks was the answer for me as well.

Was this page helpful?
0 / 5 - 0 ratings