Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有人有任何一起使用 minitest 和 reacktest 来创建请求规范的例子?
我希望能够请求资源:
get '/api/resource', format: :json
然后测试响应。
您可以按照您的建议简单地使用机架测试!编写您的规格/单元测试,并使用 rack-test 您可以:
def test_api_ressource_json get "/api/resource.json" assert last_response.ok? assert last_response.body.include?("something") # Test whatever you like with last_response.body end
应该就是这样。