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
我如何在rails(主要是消费者)中使用mocha来模拟所有这些?
答案 0 :(得分:1)
oauth_mock = mock('oauth')
OAuth::Consumer.stubs(:new).returns(oauth_mock)