【发布时间】:2016-04-04 19:04:45
【问题描述】:
所以我正在尝试为我的 API 编写一些测试
我有这个网址 /v1/users?api_key=1:--XsF99m7wcvFFzTt-Js
如果我在浏览器中访问它可以正常工作并返回一些 JSON。
但是,在我的测试中是
require 'rails_helper'
RSpec.describe "GET /users/index" do
it 'returns a 200' do
get "/v1/users?api_key=1:--XsF99m7wcvFFzTt-Js"
expect(response.status).to eq(200)
end
end
当我运行 RSpec 时,它给了我这个错误
ActionView::MissingTemplate:
Missing template v1/users/index, api_v1/index, application/index with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :jbuilder]}. Searched in:
我不明白为什么好像我将 url 粘贴到浏览器中它工作正常。
那么首先,那个 respec 测试有什么问题吗? 同样在调试方面,您打算如何调试?因为如果您通过浏览器执行此操作,我看不到任何日志文件,并且会看到 development.log 已填满
【问题讨论】:
-
这是控制器规范还是请求规范?
标签: ruby-on-rails ruby testing rspec integration-testing