spec/signet/oauth_1/client_spec.rb in signet-0.5.0 vs spec/signet/oauth_1/client_spec.rb in signet-0.5.1

- old
+ new

@@ -64,10 +64,19 @@ @client.authorization_uri.to_s.should include( 'http://example.com/authorize' ) end + it 'should allow the authorization_uri to be set to a Hash' do + @client.authorization_uri = { + :scheme => 'http', :host => 'example.com', :path => '/authorize' + } + @client.authorization_uri.to_s.should include( + 'http://example.com/authorize' + ) + end + it 'should allow the authorization_uri to be set to a URI' do @client.authorization_uri = Addressable::URI.parse('http://example.com/authorize') @client.authorization_uri.to_s.should include( 'http://example.com/authorize' @@ -81,10 +90,17 @@ it 'should allow the token_credential_uri to be set to a String' do @client.token_credential_uri = "http://example.com/" @client.token_credential_uri.should === "http://example.com/" end + it 'should allow the token_credential_uri to be set to a Hash' do + @client.token_credential_uri = { + :scheme => 'http', :host => 'example.com', :path => '/token' + } + @client.token_credential_uri.to_s.should === 'http://example.com/token' + end + it 'should allow the token_credential_uri to be set to a URI' do @client.token_credential_uri = Addressable::URI.parse("http://example.com/") @client.token_credential_uri.should === "http://example.com/" end @@ -394,9 +410,29 @@ @client.client_credential_secret = 'kd94hf93k423kf44' @client.temporary_credential_key = 'hh5s93j4hdidpola' @client.temporary_credential_secret = 'hdhd0244k9j7ao03' @client.token_credential_key = 'nnch734d00sl2jdk' @client.token_credential_secret = 'pfkkdhi9sl3r4s00' + end + + it 'should generate a JSON representation of the client' do + json = @client.to_json + json.should_not == nil + + deserialized = MultiJson.load(json) + deserialized["temporary_credential_uri"].should == + 'http://example.com/temporary_credentials' + deserialized["authorization_uri"].should include( + 'http://example.com/authorize') + deserialized["token_credential_uri"].should == + 'http://example.com/token_credentials' + deserialized["callback"].should == 'http://example.com/callback' + deserialized["client_credential_key"].should == 'dpf43f3p2l4k3l03' + deserialized["client_credential_secret"].should == 'kd94hf93k423kf44' + deserialized["temporary_credential_key"].should == 'hh5s93j4hdidpola' + deserialized["temporary_credential_secret"].should == 'hdhd0244k9j7ao03' + deserialized["token_credential_key"].should == 'nnch734d00sl2jdk' + deserialized["token_credential_secret"].should == 'pfkkdhi9sl3r4s00' end it 'should generate an authorization URI with a callback' do @client.temporary_credential_key = nil @client.authorization_uri.should ===