Created
February 4, 2011 14:07
-
-
Save mikesutton/811143 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
the error: | |
Failure/Error: client = twitterController.sign_in_as_tagoid | |
WebMock::NetConnectNotAllowedError: | |
Real HTTP connections are disabled. Unregistered request: GET https://api.twitter.com/1/account/verify_credentials.json with headers {'Accept'=>'application/json', 'Authorization'=>'OAuth oauth_consumer_key="P0O33Z4p4o0XltMlcPZ3A", oauth_nonce="962c77e088b7427895f0628fea5990f7", oauth_signature="1k%2BFVLF%2BqFlogPwNgtwD7xctJA0%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1296828033", oauth_token="14980953-MbJv9wiK8fjZtvYClI7Kyt778R0JurPIxuIOyiQFV", oauth_version="1.0"', 'User-Agent'=>'Twitter Ruby Gem 1.1.1'} | |
You can stub this request with the following snippet: | |
stub_request(:get, "https://api.twitter.com/1/account/verify_credentials.json"). | |
with(:headers => {'Accept'=>'application/json', 'Authorization'=>'OAuth oauth_consumer_key="P0O33Z4p4o0XltMlcPZ3A", oauth_nonce="962c77e088b7427895f0628fea5990f7", oauth_signature="1k%2BFVLF%2BqFlogPwNgtwD7xctJA0%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1296828033", oauth_token="14980953-MbJv9wiK8fjZtvYClI7Kyt778R0JurPIxuIOyiQFV", oauth_version="1.0"', 'User-Agent'=>'Twitter Ruby Gem 1.1.1'}). | |
to_return(:status => 200, :body => "", :headers => {}) | |
My code: | |
verification_data = File.open("#{Rails.root}/features/fixtures/verify_credentials.json", 'rb') { |file| file.read } | |
stub_request(:get, "https://api.twitter.com/1/account/verify_credentials.json"). | |
with(:headers => {'Accept'=>'application/json', 'Authorization'=>'OAuth oauth_consumer_key="P0O33Z4p4o0XltMlcPZ3A", oauth_nonce="8829efab5e19b74f6a49e7ad8ad49a86", oauth_signature="jFkvoEQSbIT5lumj%2Bqq00jndAhc%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1296557983", oauth_token="14980953-MbJv9wiK8fjZtvYClI7Kyt778R0JurPIxuIOyiQFV", oauth_version="1.0"', 'User-Agent'=>'Twitter Ruby Gem 1.1.1'}). | |
to_return(:status => 200, :body => verification_data, :headers => {}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
i mean it changes every call - will sort out.