test/unit/etsy/secure_client_test.rb in etsy-0.2.0 vs test/unit/etsy/secure_client_test.rb in etsy-0.2.1

- old
+ new

@@ -3,24 +3,46 @@ module Etsy class SecureClientTest < Test::Unit::TestCase context "An instance of the SecureClient class" do - should "be able to generate an OAuth consumer" do + should "be able to generate an OAuth consumer for the sandbox" do + Etsy.stubs(:environment).returns :sandbox + Etsy.stubs(:host).returns 'sandbox' Etsy.stubs(:api_key).returns('key') Etsy.stubs(:api_secret).returns('secret') + Etsy.stubs(:permission_scopes).returns(['scope_one', 'scope_two']) OAuth::Consumer.stubs(:new).with('key', 'secret', { - :site => 'http://openapi.etsy.com', - :request_token_path => '/v2/sandbox/oauth/request_token', - :access_token_path => '/v2/sandbox/oauth/access_token', - :authorize_url => 'https://www.etsy.com/oauth/signin' + :site => 'http://sandbox', + :request_token_path => '/v2/oauth/request_token?scope=scope_one+scope_two', + :access_token_path => '/v2/oauth/access_token', }).returns('consumer') client = SecureClient.new client.consumer.should == 'consumer' end + + should "be able to generate an OAuth consumer in production" do + Etsy.stubs(:environment).returns :production + Etsy.stubs(:host).returns 'production' + Etsy.stubs(:api_key).returns('key') + Etsy.stubs(:api_secret).returns('secret') + Etsy.stubs(:permission_scopes).returns(['scope_one', 'scope_two']) + + OAuth::Consumer.stubs(:new).with('key', 'secret', { + :site => 'http://production', + :request_token_path => '/v2/oauth/request_token?scope=scope_one+scope_two', + :access_token_path => '/v2/oauth/access_token', + }).returns('consumer') + + client = SecureClient.new + + client.consumer.should == 'consumer' + end + + should "be able to generate a request token" do Etsy.stubs(:callback_url).with().returns('callback_url') consumer = stub() {|c| c.stubs(:get_request_token).with(:oauth_callback => 'callback_url').returns('toke') }