Sha256: 35793f7820cb90fb1c227a190bbfe1fddbbbd45951ef29f871c163f40d56276d

Contents?: true

Size: 1.59 KB

Versions: 7

Compression:

Stored size: 1.59 KB

Contents

require 'spec_helper'

describe Ivapi::Client do
  after(:each) do
    Ivapi.reset!
  end

  it 'works with basic auth and password' do
    expect { Ivapi::Client.new(username: 'foo', password: 'bar') }
      .not_to raise_exception
  end

  describe 'authentication' do
    it 'should possible to authenticate with configure' do
      Ivapi.configure do |config|
        config.username = 'foo'
        config.password = 'bar'
      end

      expect(Ivapi.client).to be_authenticated
    end

    it 'should possible to authenticate with basic username and password' do
      client = Ivapi::Client.new(username: 'foo', password: 'bar')
      expect(client).to be_authenticated
    end

    it 'should not possible to authenticate without username and password' do
      client = Ivapi::Client.new
      expect(client).to_not be_authenticated
    end
  end

  describe 'setting server id from client' do
    it 'should not have server id' do
      client = Ivapi::Client.new(username: 'foo', password: 'bar')
      expect(client.server_id).to be_nil
    end

    it 'should have server id when set manualy' do
      client = Ivapi::Client.new(username: 'foo', password: 'bar', server_id: 3)
      expect(client.server_id).to eq(3)
    end
  end

  describe 'manualy setting server id' do
    before(:each) do
      Ivapi.configure do |config|
        config.username = 'foo'
        config.password = 'bar'
      end
    end

    it 'should not have server id' do
      expect(Ivapi.server_id).to be_nil
    end

    it 'should have server id when set manualy' do
      expect(Ivapi.server(3).server_id).to eq(3)
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ivapi-1.5.0 spec/ivapi/client_spec.rb
ivapi-1.4.0 spec/ivapi/client_spec.rb
ivapi-1.3.0 spec/ivapi/client_spec.rb
ivapi-1.2.0 spec/ivapi/client_spec.rb
ivapi-1.1.8 spec/ivapi/client_spec.rb
ivapi-1.1.7 spec/ivapi/client_spec.rb
ivapi-1.1.6 spec/ivapi/client_spec.rb