Created
November 7, 2010 18:30
-
-
Save cheeyeo/666307 to your computer and use it in GitHub Desktop.
Failing Webmock rspec test
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
describe 'making requests to SNS API' do | |
before :each do | |
AmazeSNS.akey = '123456' | |
AmazeSNS.skey = '123456' | |
@time_stub = stub("Time") | |
WebMock.reset! | |
WebMock.disable_net_connect! | |
@url = 'http://sns.us-east-1.amazonaws.com:80/?Action=CreateTopic&Signature=t8VXbA2gjfYwaBO9C9MtySwGjUphjhtgNBUZBxbuOrU%3D&Name=MyTopic&AWSAccessKeyId=123456&Timestamp=123&SignatureVersion=2&SignatureMethod=HmacSHA256' | |
end | |
it 'should send data to the API' do | |
@time_stub.should_receive(:iso8601).and_return(123) | |
Time.stub(:now).and_return(@time_stub) | |
data = <<-RESPONSE.gsub(/^ +/, '') | |
<CreateTopicResponse xmlns="http://sns.amazonaws.com/doc/2010-03-31/"> | |
<CreateTopicResult> | |
<TopicArn>arn:aws:sns:us-east-1:365155214602:MyTopic</TopicArn> | |
</CreateTopicResult> | |
<ResponseMetadata> | |
<RequestId>0a7225aa-e9cb-11df-a5a1-293a0b8d0fcb</RequestId> | |
</ResponseMetadata> | |
</CreateTopicResponse> | |
RESPONSE | |
EM.run{ | |
stub_http_request(:get, "http://sns.us-east-1.amazonaws.com:80").with(:query=>{"Query" => "CreateTopic","Signature" => "t8VXbA2gjfYwaBO9C9MtySwGjUphjhtgNBUZBxbuOrU%3D", "Name" => "MyTopic","AWSAccessKeyId" => "123456", "Timestamp" => "123","SignatureVersion" => "2","SignatureMethod" => "HmacSHA256"}).to_return(:status => 200,:body => data) | |
@arn = AmazeSNS["MyTopic"].create | |
WebMock.should have_requested(:get, %r{http://sns.us-east-1.amazonaws.com:80}) | |
EM.stop | |
} | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment