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.
Corresponding source code
Error message Failure/Error: expect (response.status) .to eq 200 expected: 200 got: 401 (compared using ==)
What I tried
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
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.
Please provide more detailed information here.
Answer # 1
If authentication is also required for the root path, you need to log in before get root_path.
The mechanism depends on what you are using login, so please provide information about that.
- ruby on rails - i want to sort the search results
- ruby on rails - [rails] i want to pass json from controller to html (erb)
- ruby on rails - i want to move to the product purchase page
- ruby on rails 6 - i want to save data from one form to multiple tables at the same time
- ruby on rails - i want to save the purchase information in the db
- ruby on rails - i want to deploy to aws ec2 server
- ruby - i want to use two rails renders
- ruby on rails - i want to eliminate nomethoderror
- ruby on rails - i want to erase www on heroku
- ruby on rails - i want to display "sold out" when the product is sold
- i want to have data for each prefecture with ruby on rails
- ruby on rails - i want to display the details page
- ruby on rails - how to set the path to move from the top page to the new registration page
- ruby on rails - i want to display a list of liked data
- ruby on rails - i want to save data in an intermediate table
- ruby on rails - i want to launch rails with a new file
- ruby on rails - i want to add a class to link_to
- ruby - rails can't log in
- ruby on rails - i want to be able to send emails from the rails production environment
- ruby on rails - how to resolve lib/rack/session/abstract/idrb: 375: in'commit_sesion' that occurs in rspec
- ruby - [rspec] error in "dependent: destoy" test: how to resolve "validation failed"
- ruby on rails - i want to write a test code that matches the rspec value
- ruby - rails tutorial chapter 13 delete does not work in the test of increasing/decreasing the number of posts with rspec
- ruby - [rails/rspec] intermediate table model test does not pass
- ruby - [rspec] destroy action test does not pass
- ruby on rails - how to test that a specific element has a class name using rspec/capybara
- ruby on rails - rails rspec argumenterror occurs when the mock under test has arguments
- ruby on rails - i want to write a rails tutorial test in rspec