Sha256: 8c87112f42475f8f0f0346e588682d2ff0f6f4e6bfac2c5bb9975a0b16447338

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

require 'spec_helper'

describe WialonApi::Authorization do
  describe '.authorize' do
    let(:success) { Hashie::Mash.new(eid: 'sid') }
    let(:error) { Hashie::Mash.new(error: '8') }
    let(:credentials) { ['user', 'password'] }

    it 'bulds a WialonApi client if the credentials are correct' do
      allow(WialonApi::Api).to receive(:call).and_return(success)
      expect(WialonApi::Client).to receive(:new).with('sid')
      WialonApi.authorize(*credentials)
    end

    it "uses ssid with wialon pro edition" do
      success = Hashie::Mash.new(ssid: 'sid')
      allow(WialonApi::Api).to receive(:call).and_return(success)
      WialonApi.configure do |config|
        config.wialon_edition = :pro
      end
      expect(WialonApi::Client).to receive(:new).with('sid')
      WialonApi.authorize(*credentials)
    end

    it 'raises an error if password or login do not match' do
      allow(WialonApi::Api).to receive(:call).and_return(error)
      expect { WialonApi.authorize(*credentials) }.to raise_error(WialonApi::Error)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wialon_api-0.0.5 spec/wialon_api/authorization_spec.rb