Home>

Please write your question in detail here.
(Example) I am making a ●● system with PHP (CakePHP).
■■ The following error message occurred while implementing the function.

I'm new to rails. The original app is under construction.
I have written the test code for the tweet controller, but the response.status is 401.
I want to make it 200.

Error message
Failure/Error: expect (response.status) .to eq 200
       expected: 200
            got: 401
       (compared using ==)
Corresponding source code
rails RSpec
Source code
require'rails_helper'
describe TweetsController, type :: request do
  before do
    @tweet = FactoryBot.create (: tweet)
  end
  describe "GET #index" do
    it "When I request an index action, a response is returned normally" do
      get root_path
      expect (response.status) .to eq 200
    end
What I tried

I saw that number 401 is related to login, so I also included basic authentication in the app, so vim ~/.zshrc and
I also checked application_controller.rb, but it wasn't. Also, the ID and PASSWORD displayed when the app was started were correct.

Supplementary information (FW/tool version, etc.)

Please provide more detailed information here.