【发布时间】:2016-06-28 00:07:38
【问题描述】:
当我转到 localhost:3000/api/guests/1 时,我得到了我的显示页面,但是当我运行规范时,它没有通过。
这是我的规格:
it 'the resource is under the correct namespace' do
get '/api/guests/1'
expect(response).to be_success
end
这是我的路线.rb:
Rails.application.routes.draw do
namespace :api, defaults: { format: :json } do
resources :gifts, only: :show
resources :guests, only: [:index, :show] do
resources :gifts, only: :index
end
resources :parties, only: [:index, :show]
end
end
这是我的 RSpec 失败消息:
ActiveRecord::RecordNotFound:
Couldn't find Guest with 'id'=1
我不太确定从哪里寻找问题。
【问题讨论】:
标签: ruby-on-rails ruby json rspec