Skip to content

Commit

Permalink
update AccessToken specs to ensure that POST/PUT/DELETE requests enco…
Browse files Browse the repository at this point in the history
…de the params in the request body
  • Loading branch information
technoweenie committed Apr 27, 2010
1 parent 6d05485 commit 9b81fa0
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions spec/oauth2/access_token_spec.rb
Expand Up @@ -5,10 +5,10 @@
cli = OAuth2::Client.new('abc','def', :site => 'https://api.example.com')
cli.connection.build do |b|
b.adapter :test do |stub|
stub.get('/client?access_token=monkey') { |env| [200, {}, 'get'] }
stub.post('/client') { |env| [200, {}, 'post'] }
stub.put('/client') { |env| [200, {}, 'put'] }
stub.delete('/client') { |env| [200, {}, 'delete'] }
stub.get('/client?access_token=monkey') { |env| [200, {}, 'get'] }
stub.post('/client') { |env| [200, {}, 'access_token=' << env[:body]['access_token']] }
stub.put('/client') { |env| [200, {}, 'access_token=' << env[:body]['access_token']] }
stub.delete('/client') { |env| [200, {}, 'access_token=' << env[:body]['access_token']] }
end
end
cli
Expand All @@ -24,9 +24,13 @@
subject.token.should == token
end

%w(get post put delete).each do |http_method|
it "makes GET requests with access token" do
subject.send(:get, 'client').should == 'get'
end

%w(post put delete).each do |http_method|
it "makes #{http_method.upcase} requests with access token" do
subject.send(http_method.to_sym, 'client').should == http_method
subject.send(http_method.to_sym, 'client').should == 'access_token=monkey'
end
end
end
Expand Down

0 comments on commit 9b81fa0

Please sign in to comment.