Sha256: 2cd8bbf0e5239fe609da79de5501199e74f88e15174f4eeccb3c4c11a1ecf6a2

Contents?: true

Size: 1.06 KB

Versions: 4

Compression:

Stored size: 1.06 KB

Contents

require File.expand_path('../../../spec_helper', __FILE__)

describe OAuth2::Grant::DeviceCode do

  before :all do
    @host           = 'example.com'
    @client_id      = 's6BhdRkqt3'
    @client_secret  = 'SplxlOBeZQQYbYS6WxSbIA'
    @client = OAuth2::Client.new(@host, @client_id, @client_secret)
  end

  subject do
    OAuth2::Grant::DeviceCode.new(@client)
  end

  describe "#grant_type" do
    it "returns grant type" do
      expect(subject.grant_type).to eq 'http://oauth.net/grant_type/device/1.0'
    end
  end

  describe "#get_code" do
    it "gets user code" do
      subject.should_receive(:make_request).with(:post, "/oauth2/device/code", {
        :params => {:client_id=>"s6BhdRkqt3"}
      })
      subject.get_code
    end
  end

  describe "#get_token" do
    it "gets access token" do
      subject.should_receive(:make_request).with(:post, "/oauth2/token", {
        :params       => {:code=>"G3Y6jU3a", :grant_type=>"http://oauth.net/grant_type/device/1.0"}, 
        :authenticate => :headers
      })
      subject.get_token('G3Y6jU3a')
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
oauth2-client-1.1.3 spec/oauth2/grant/device_spec.rb
oauth2-client-1.1.2 spec/oauth2/grant/device_spec.rb
oauth2-client-1.1.1 spec/oauth2/grant/device_spec.rb
oauth2-client-1.1.0 spec/oauth2/grant/device_spec.rb