I am working on MVP (minimum viable product). To offer an easier way to protect admin pages, I just added http_basic_authenticate_with to my AdminController.
The problem is that when I want to test my AdminController, I get "unauthorized" (401) for not logging in.
In this case, it does not make sense to check the authentication - it is just temporary, and as soon as I move to the next sprint, it will be deleted - so I try to skip it in RSpec.
The problem is that I tried many ways and nobody seems to work.
For example, I tried changing http_basic_authenticate_with to avoid authentication. Like this:
require 'spec_helper' module ActionController module HttpAuthentication module Basic def http_basic_authenticate_with(*args) end end end end describe Admin::SubscribersController do describe "GET 'index'" do it "should be OK" do get 'index' response.should be_successful end end end
But when I run it, it still returns false for this simple test.
Btw, to simplify this test, I just have an action with an empty index on my AdminController and an empty view (index.html.erb).
source share