MiniTestでBasic認証を通したい
RailsでBasic認証を導入したサービスのテストを書きたいのですが、
下記のエラーメッセージが出てしまい困ってます。
Expected response to be a <2XX: success>, but was a <401: Unauthorized> Response body: HTTP Basic: Access denied.
該当のソースコード
welcome_controller_test.rb
1require 'test_helper' 2 3class WelcomeControllerTest < ActionDispatch::IntegrationTest 4 setup do 5# ActionControler.http_basic_authenticate_with( 6# name: Rails.application.credentials.basic[:name], 7# password: Rails.application.credentials.basic[:password] 8# ) 9# @request.headers['Authorization'] = ActionController::HttpAuthentication::Basic.encode_credentials('name', 'password') 10 end 11 12 test "should get index" do 13 get welcome_index_url 14 assert_response :success 15 end 16end 17
よろしくお願いしますー。。
ruby 2.5.1
Rails 5.2.1
あなたの回答
tips
プレビュー