5
네임 스페이스가 지정된 컨트롤러에 대해 RSpec 컨트롤러 테스트를 만들려고 시도했지만 rspec이 중첩을 감지하지 못했고 post :create
동작에 대한 적절한 경로를 생성하지 못하는 것 같습니다. RSpec 컨트롤러 테스트에서 올바른 URL이 생성되지 않음
이
내 사양 코드 :이 코드에 대한# for: /app/controllers/admin/crm/report_adjustments_controller.rb
require 'spec_helper'
describe Admin::Crm::ReportAdjustmentsController do
render_views
before(:each) do
signin
end
describe "GET 'index'" do
it "returns http success" do
get :index
response.should be_success
end
end
describe "POST 'create'" do
it "creates with right parameters" do
expect {
post :create, report_adjustment: {distributor_id: @ole_distributor.id, amount: "30.0", date: Date.today }
}.to change(Crm::ReportAdjustment, :count).by(1)
response.should be_success
end
end
end
# routes.rb
namespace :admin do
namespace :crm do
resources :report_adjustments
end
end
의 get :index
작품을 잘하지만, post :create
가 호출 될 때, 다음과 같은 오류가 생성됩니다 undefined method 'crm_report_adjustment_url'
것은 왜 RSpec에 충분히 똑똑한 것 get :index
으로 문제를 해결할 수 있지만 post :create
으로 해결할 수는 없습니까? RSpec이 올바른 경로를 올바르게로드하도록하려면 어떻게해야합니까? admin_crm_report_adjustments_url
?
미리 감사드립니다. 대신 URL에
모두': get'와': post'이 같은 처리해야한다. 요청 물건을 처리하는'process'를보십시오 : http://apidock.com/rails/v3.2.13/ActionController/TestCase/Behavior/process 당신은 어플리케이션에서 디버깅을 시도 할 수 있습니다. 디버거를 사용하거나 – phoet
을 넣으십시오. 나는 같은 문제를 겪고있다. 해결책은 @roflmao인가? – dwhite