Rspec-rails: DEPRECATION WARNING: `named_routes.helpers` is deprecated, please use `route_defined?(route_name)` to see if a named route was defined. (called from block in it_requires_authentication

Created on 7 Oct 2014  路  8Comments  路  Source: rspec/rspec-rails

Hi guys. I wrote rspec spec And I had:

DEPRECATION WARNING: `named_routes.helpers` is deprecated, please use `route_defined?(route_name)` to see if a named route was defined. (called from block in it_requires_authentication at /Users/vorob/Dropbox/ruby/upnetwork/spec/support/controllers/errors_helper.rb:7)

See my _/Users/vorob/Dropbox/ruby/upnetwork/spec/support/controllers/errors_helper.rb_

module Controllers
  module ErrorsHelper
    def it_requires_authentication(&block)
      it 'requires authentication' do
        instance_exec(&block)

        expect(response).not_to be_successful
        expect(flash[:alert]).to eq(I18n.t('devise.failure.unauthenticated'))
      end
    end

    def it_raises_authorization_error(in_case = nil, &block)
      it "raises authorization error #{in_case}" do
        instance_exec(&block)

        expect(response).not_to be_successful
        expect(flash[:alert]).to eq(I18n.t('errors.not_authorized'))
      end
    end
  end
end

I use

  gem 'rspec-rails', '~> 3.0'

Most helpful comment

I changed version from _3.0_ to _3.1_ and it works fine.

gem 'rspec-rails', '~> 3.1'

Tnx)

All 8 comments

Could you please add your exact RSpec, Rails, and Ruby versions?

Looks related to #1142. Rails 4.2 support starts with rspec-rails 3.1, please make sure you're using this setup.

I changed version from _3.0_ to _3.1_ and it works fine.

gem 'rspec-rails', '~> 3.1'

Tnx)

@cupakromer do you think it would be an idea to issue a warning when using Rails 4.2 on 3.0?

@JonRowe i would like to do something. We could put the warning in, we also could update the gemspec too. I'm not sure what's best or better long term.

is this on rspec 2 too?

@arthurnn it is not, we are not supporting Rails 4.2 on RSpec 2. If you are looking for help upgrading to RSpec 3 check out the main upgrade guide the rails specific changes and the amazing tool transpec which automates a huge portion of the process.

@cupakromer thanks. I will do that.

Was this page helpful?
0 / 5 - 0 ratings