0
我有以下代碼模擬「」收到意外的消息
Class Client
def initialize(options = {})
@key = options['oauth_key']
@secret = options['oauth_secret']
@access_token_url = options['oauth_access_token_url']
@signature_method = options['signature_method']
@consumer = OAuth::Consumer.new(@key, @secret, {access_token_url: @access_token_url, signature_method: @signature_method})
end
def accounts_by_id(account_id)
response = query_account(account_id)
parse_json(response)
end
private
def access_token()
...
...
...
@access_token = @consumer.get_access_token(nil)
...
end
消費者一直嘲笑如下
oauth_mock = mock('oauth')
OAuth::Consumer.stubs(:new).returns(oauth_mock)
但是我得到一個模擬「的OAuth」收到意外的消息:get_access_token with (nil)
當我這樣做a
GameSystem::Client.new(oauth_key: 'KEY',oauth_secret: 'SECRET',oauth_access_token_url: 'http://localhost').accounts_by_id("kk")
access_token方法在query_account中被調用。是否有人知道ho我也可以嘲笑這個來克服這個問題。
嘿吉姆...這有助於......謝謝你......沒有意識到我發佈了兩次問題 – user2217348 2013-03-28 18:50:29