Bleed: ranger even with Devise :: TestHelpers included

I am creating a Rails JSON API and am trying to write tests to ensure requests without a valid auth_token that correspond to 401 status.

I have included Devise test helpers in both my spec_helper.rb ( config.include Devise::TestHelpers, type: :controller) and my controller specification (shown below). I also install @request.env['devise.mapping'] = Devise.mappings[:user]before each test. All my tests, when the user is authenticated correctly, work fine, but any unauthorized requests result in:

 ArgumentError:
    uncaught throw :warden

Since Devise removed their implementation: token_authenticatable, I adapted the more secure solution described here .

You can also note that I use rails-api gem, so my ApplicationController inherits from ActionController :: API, not Base.

I browsed the Internet and many, many questions regarding this error and tried everything I could, but no luck. As far as I know, there should be enough Devise test assistants, as they should catch: overseers throw and give the corresponding 401.

Any suggestions you could provide would be greatly appreciated, and I can correct this issue with more details if necessary. Thank!

+4
source share

All Articles