2013-05-08 4 views
1

레일즈 2.3.18에서 3.2.x로 업그레이드 중이며 컨트롤러 테스트에서이 한 세트의 문제가 발생했습니다 :정의되지 않은 메소드 relative_url_root for nil : 네임 스페이스 컨트롤러에서 rspec을 실행할 때 NilClass

오류 :

/actionpack-3.2.12/lib/action_controller/test_case.rb:514:in `build_request_uri' 
/actionpack-3.2.12/lib/action_controller/test_case.rb:470:in `process' 
/actionpack-3.2.12/lib/action_controller/test_case.rb:49:in `process' 
/actionpack-3.2.12/lib/action_controller/test_case.rb:390:in `get' 
# ./spec/controllers/integrations/formstack_controller_spec.rb:104:in `block (3 levels) in <top (required)>' 

코드 트리거 오류 :이 컨트롤러에 대한

it "should handle a failed access_token retreival" do 
    FormStack::Oauth2Connection.any_instance.stub(:identify).and_return(nil) 
    get "oauth_token" # this line <---------------------------------------------------------------- 104 
    response.should redirect_to(:controller => "/integrations/", :action => :index) 
    flash[:error].should include("error") 
end 

경로 :

012 내 컨트롤러에 대한 특별 36,

아무것도 :

class Integrations::FormstackController < ApplicationController 
    def oauth_token 
     ... 
    end 
end 

그래서 약

get "any_action_in_this_controller" 

는이 relative_url_root 오류가 발생 무엇입니까? 이 컨트롤러의 모든 작업에 대한 모든 테스트에서 오류가 발생합니다.

내가 디버깅하는 데 도움이되는 다른 정보를 알려주십시오.

당신이있는 경우, @marcario에서 언급 한 바와 같이
+0

여기에서와 같이 작동시킬 수 있습니까? 내 컨트롤러도 네임 스페이스입니다 ... – Macario

+2

컨트롤러는 config라는 작업을 할 수 없으며 문제의 이름을 바꿔서 문제를 해결했습니다 – Macario

답변

3

: 컨트롤러에서

def config 
    end 

, 당신은이 (모호한) 오류가 발생합니다. config의 이름을 다른 이름으로 바꾸고 경로 매핑을 일치 시키면 좋습니다.

+0

저는 오래전에 이걸 발견했습니다. 답변을 게시 해 주셔서 감사합니다. 바라건대 다른 사람들은 내가했던 것처럼 좌절하지 않을 것입니다. ha – NullVoxPopuli

+0

이것은 이상한 것입니다. 2016 년 7 월 26 일까지 작동합니다. 감사합니다. – luispcosta