spec/sucker/request_spec.rb in sucker-2.0.0.pre.4 vs spec/sucker/request_spec.rb in sucker-2.0.0.pre.5

- old
+ new

@@ -3,22 +3,16 @@ module Sucker describe Request do use_vcr_cassette 'spec/sucker/request', :record => :new_episodes let(:request) do - Request.new( - :locale => :us, - :key => 'key', - :secret => 'secret') + Request.new(:locale => :us, + :key => 'key', + :secret => 'secret', + :associate_tag => 'tag') end - describe ".locales" do - it "returns available locales" do - Request.locales.should =~ [:us, :uk, :de, :ca, :fr, :jp] - end - end - describe '#<<' do it 'merges a hash into the existing parameters' do request << { 'foo' => 'bar' } request.parameters['foo'].should eql 'bar' end @@ -37,12 +31,12 @@ request.parameters['Service'].should_not be_nil request.parameters['foo'].should be_nil end - it "returns the request object" do - request.reset.should be_a Request + it "returns itself" do + request.reset.should eql request end end describe '#url' do it 'builds a URL' do @@ -61,11 +55,11 @@ let(:query) do request.send(:build_query_string) end it 'canonicalizes query' do - query.should match /AWSAccessKeyId=key&AssociateTag=&Service=([^&]+)&Timestamp=([^&]+)&Version=([^&]+)/ + query.should match /AWSAccessKeyId=key&AssociateTag=tag&Service=([^&]+)&Timestamp=([^&]+)&Version=([^&]+)/ end it 'includes a timestamp' do query.should include 'Timestamp' end @@ -88,13 +82,13 @@ it 'URL-encodes a string' do request.send(:escape, 'foo,bar').should eql 'foo%2Cbar' end end - describe '#host' do - it 'returns a host' do - request.locale = :fr - request.send(:host).should eql 'ecs.amazonaws.fr' + describe "#host" do + it "returns the host for specified locale" do + request.locale = :uk + request.send(:host).should eql Request::HOSTS[request.locale] end end end end