2013-03-25 68 views
1
describe GameSystem::Client do 

    def client 
    GameSystem::Client.new(signature_method: 'HMAC-SHA1', oauth_key: 'kk', oauth_secret: 'bb', oauth_access_token_url: 'https:://localhost') 
    end 

    before :each do 
    WebMock.reset!  
    end 

    describe 'response' do 

    context 'wrong path' do 
     it 'raises JSON::ParserError on invalid return value' do 
     stub_request(:get,"https://games.com/game_id/invalid_id").to_return(:status => 200, :body => 'invalid json', :headers => {}) 
     Rails.logger.info "#{client.games_by_id("invalid_id")}" 
     end 
    end 
    end 

end 

任何人都可以让我知道我一直在做错什么,或者我可以做什么不同吗?未定义的方法'downcase'为零:NilClass

它基本上在我的客户

回答

0

在该行

@access_token = @consumer.get_access_token(nil)抛出这个错误它会是很好的,如果你能成为你正在试图做什么更具体一点。

这个错误很自我解释。你得到downcase for nil:NilClass,因为你正在试图拨打downcase作为零对象......提供更多信息,我们将能够提供更好的帮助。

+1

他实际上并没有在他的代码中任何地方调用downcase。 – doug

+0

也许这个答案应该是一个评论。然而,问题仍然存在,他的代码必须在无对象的地方调用'downcase'...他从来没有提供方法'get_access_token'的代码,这可能是在哪里downcase ... –

0

我意识到这个问题是从回来的,但我刚刚在一个测试套件中遇到了这个问题。听起来很熟悉。

我的错误是

Failure/Error: get :index 
    ActionView::Template::Error: 
    undefined method `downcase' for nil:NilClass 

事实证明,我使用mobile-fu,我被磕碰is_mobile_device?不也mobile_device磕碰。一路上,mobile-fu正试图压低设备名称,这是nil。通过为mobile_device添加一个存根,事情就清除了。在规格的前面块中,我补充说:

controller.stub(:is_mobile_device? => true, :mobile_device => 'iphone') 

如果您不使用mobile-fu,您可能会遇到不同的问题。我能够跟踪prypry-debugger的实际问题。绝对值得探索的工具。

相关问题