shared_examples "HTTP Basic Auth Required" do it "should not allow unauthorized access" do get action, action_params response.status.should eq(401) end it "should allow authorized access" do request.env['HTTP_AUTHORIZATION'] = ActionController::HttpAuthentication::Basic.encode_credentials("usertesting","usertesting") get action, action_params response.status.should eq(200) end end