0
각 컨트롤러에 대한 요청을 테스트하지 않아도되는 응용 프로그램 (API)이 있습니다. items_controller_spec.rb에서RSpec 중첩 된 경로와 일치하는 경로가 없습니다.
resources :items do
resources :offers, only: [:index, :create, :destroy, :update] do
put :accept, on: :member
end
end
다음 작품 잘 :
require 'spec_helper'
describe ItemsController do
user = FactoryGirl.create(:user)
item = user.items.create()
context "GET #index" do
it 'returns unauthorised - 401 when not logged in' do
get :index
# test for the 401 unauthorised
expect(response.status).to eq(401)
end
it 'returns 200 and users items when logged in' do
get :index , { access_token: user.token }
expect(response.status).to eq(200)
end
end
end
같은 코드가 작동하고 다음과 같은 오류 발생하지 않습니다 offers_controller_spec.rb에서 :
을 나는 다음과 같은 경로를 가지고1) OffersController GET #index shows something
Failure/Error: get :index
ActionController::UrlGenerationError:
No route matches {:action=>"index", :controller=>"offers"}
# ./spec/controllers/offers_controller_spec.rb:8:in `block (3 levels) in <top (required)>'
경로가 중첩되어 있기 때문에 요청을 다른 방식으로 테스트해야합니까? 여러 가지 시도를했지만 아무 것도 작동하지 않는 것 같습니다. 모든 포인터 크게 감사하겠습니다.