2013-06-23 1 views
2

내 사용자 리소스에 대해 다음과 같은 경로가 있으며, 사양에 경로가 존재하지 않는다는 오류가 표시됩니다.하위 도메인 제약이 사양을 찾지 못했습니다.

업데이트 : 사양을 자체적으로 실행할 때 테스트가 통과 된 것 같습니다. 하지만 전체 제품군을 실행할 때가 아닙니다.

사양 :

describe 'POST #create' do 
    let(:perform_request) do 
    post :create, user: FactoryGirl.attributes_for(:user), subdomain: 'api', format: :json 
    end 

    it 'should be successful' do 
    perform_request 
    response.should be_a_success 
    end 

    it 'should create the user' do 
    expect { perform_request }.to change { User.count } 
    end 

    it 'should assign the device to the user' do 
    expect { perform_request }.to change { controller.send(:current_device).reload.user } 
    end 
end 

경로 :

Server::Application.routes.draw do 
    scope module: :api, constraints: { subdomain: 'api' }, as: :api, defaults: { format: :json } do 
    resource :user do 
     resource :emergency_contact, controller: :contacts, only: [:create, :show, :update, :destroy] 
     resources :activities, only: [:create, :show, :update, :destroy, :index] 
    end 
    get '/*path' => 'application#invalid_url' 
    end 
end 

오류 :

1) Api::UsersController POST #create should be successful 
    Failure/Error: post :create, user: FactoryGirl.attributes_for(:user), subdomain: 'api', format: :json 
    ActionController::RoutingError: 
    No route matches {:user=>{:first_name=>"Josh", :last_name=>"Stokes", :phone_number=>"(555) 555-1003", :password=>"qwertyuiop", :password_confirmation=>"qwertyuiop"}, :subdomain=>"api", :format=>:json, :controller=>"api/users", :action=>"create"} 
    # ./spec/controllers/api/users_controller_spec.rb:10:in `block (3 levels) in <top (required)>' 
    # ./spec/controllers/api/users_controller_spec.rb:14:in `block (3 levels) in <top (required)>' 

답변

0

사양을 조사한 결과 사양을 다시로드하면 문제가 해결 된 것으로 보입니다.

before(:all){ Rails.application.reload_routes! } 
관련 문제