2011-09-15 1 views
2
it "should match login for existing account" do 
    { :get => 'http://www.' + @business.subdomain + '.lvh.me:3000/login' }.should route_to({:controller => "go", :action => "index"}) 
end 

match '/login' => 'admin/calendars#index' # this one should actually work, but fails: 

The recognized options <{"controller"=>"errors", "action"=>"handle404", "a"=>"login"}> did not match <{"controller"=>"go", "action"=>"index"}>, difference: <{"controller"=>"go", "action"=>"index", "a"=>"login"}>. 

여기에 특정 컨트롤러 # 경로가 존재 나열된 하위 디렉토리 (또는 중첩 된 경로)가있을 때 휴식을 보이지만, 디렉토리/중첩 된 경로 ('관리자/') 실패를 일으키는 것 같습니다. 라우트가 존재하지 않더라도 지정된 라우트 ('calendars # index')가 존재하지 않는다는 점을 감안할 때 다음 라우팅과 같은 방식으로 실패합니다. 결과로 나온 경로의 존재 여부는 중요하지 않습니다. 이는 매핑이 작동하는지 테스트하는 것으로 간주되기 때문입니다. 이 문제를 어떻게 해결할 생각인가요?RSpec에이 경로 '일치'문

match '/login' => 'calendars#index' #this one fails as expected: 

The recognized options <{"controller"=>"calendars", "action"=>"index"}> did not match <{"controller"=>"go", "action"=>"index"}>, difference: <{"controller"=>"go"}> 

답변

0

테스트 경로의 건물이 잘못되었습니다 :

it "should match login for existing account" do 
    { :get => 'http://www.' + @business.subdomain + '.lvh.me:3000/login' }.should route_to({:controller => "go", :action => "index"}) 
end 

아마 읽어야

it "should match login for existing account" do 
    { :get => 'http://' + @business.subdomain + '.lvh.me:3000/login' }.should route_to({:controller => "go", :action => "index"}) 
end 

을 같은 아마도 당신이 http://foo.lvh.me/etc하지 http://www.foo.lvh.me

을 테스트 할