2015-01-27 2 views
0

하위 도메인과 함께 RSpec에 대한 경로를 제공 할 수 없습니다. 테스트 경로는 api.example.com/public/v1/regions/origin?title=indmRSpec 테스트가 하위 도메인 경로와 함께 실패합니다.

이어야합니다. 그러나 RSpec에 대한 경로를 제공하는 방법을 모르겠습니다. 하위 도메인 api을이 상대 경로로 경로 지정하는 방법?

let(:api_path) { 'public/v1/regions/origin?title=indm' } 

로그

1) Regions Public API GET /v1/regions/origin?title=? returns 200 status code 
    Failure/Error: get api_path 
    ActionController::RoutingError: 
     No route matches [GET] "/public/v1/regions/origin" 
    # ./spec/api/public/v1/regions_spec.rb:14:in `block (3 levels) in <top (required)>' 

namespace :api, path: '', constraints: {subdomain: 'api'} do 
    namespace :public, defaults: { format: :json } do 
     namespace :v1 do 
     resources :regions do 
      get :origin, on: :collection 
      get :destination, on: :collection 
     end 
     end 
    end 
    end 

답변

0

나는이 문제를 해결하는 정말 좋은 방법을 모르는 routes.rb,하지만 난 그것을 pow 서버를 사용 않았다 앤빌과. Anvil을 설치하고 orca.dev 도메인의 서버를 실행했습니다. 이 후 나는 RSpec 테스트 경로를 재구성했다.

spec_helper.rb

def get_api_path path, *args 
    get "http://api.orca.dev#{path}", *args 
end 

regions_spec.rb

before do 
    get_api_path '/public/v1/regions/origin?title=indm' 
end 

이제 테스트 작업!

관련 문제