我发现其他人发布了很多类似的问题,但没有一个解决方案有效。
我的 /spec/requests/questions_spec.rb 是
require 'rails_helper'
RSpec.describe "Questions", type: :request do
describe "GET /questions" do
it "works! (now write some real specs)" do
get questions_path
expect(response).to have_http_status(200)
end
end
end
现在我的 rspec 错误
Questions GET /questions works! (now write some real specs)
Failure/Error: expect(response).to have_http_status(200)
expected the response to have status code 200 but it was 302
# ./spec/requests/questions_spec.rb:7:in `block (3 levels) in <top (required)>'
谁能帮我?如何自定义代码以获得状态代码 200 ?
302 - Found
。我认为你正在使用轨道脚手架。支架语法在 get 方法上返回 302 状态。如果您需要200。您可以自定义您的代码。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)