Sha256: cb3571c6530e15f992316eb634586d512dbba900ecbd0816272af81dea69807f

Contents?: true

Size: 1.2 KB

Versions: 3

Compression:

Stored size: 1.2 KB

Contents

require 'spec_helper'

describe Gocoin::Auth do
	
	describe "'auth' method" do

		it "should raise an error if an improper grant_type is specified" do
			@gocoin_client = Gocoin::Client.new(grant_type: 'invalid_grant_type')
			expect{@gocoin_client.auth.authenticate}.to raise_error 'Gocoin::Auth#authenticate: grant_type was not defined properly or is unsupported'
		end

		it "should raise an error if missing required properties for authorization_code grant_type" do
			@gocoin_client = Gocoin::Client.new(
				grant_type: 'authorization_code',
				client_id: 'someid',
				client_secret: 'somesecret',
				redirect_uri: 'someuri'
			)
			expect{@gocoin_client.auth.authenticate}.to raise_error "Gocoin::Auth#authenticate requires 'code' option."
		end

	end

	describe "'construct_code_url' method" do

		it "should create and return an authorization_code url" do
			@gocoin_client = Gocoin::Client.new(
				grant_type: 'password',
				client_secret: 'somesecret',
				username: 'admin@gocoin.com',
				password: 'password123',
				scope: 'user_read'
			)
			url = @gocoin_client.auth.construct_code_url param_key: 'param_value'
			url.should == 'https://dashboard.gocoin.com/auth?param_key=param_value'
		end

	end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gocoin-0.1.4 spec/gocoin/auth_spec.rb
gocoin-0.1.3 spec/gocoin/auth_spec.rb
gocoin-0.1.2 spec/gocoin/auth_spec.rb