Sha256: c92f90e22988695b00468654874409e3f9b84fb4ef73270576d3f92ed7eb31be

Contents?: true

Size: 1.16 KB

Versions: 6

Compression:

Stored size: 1.16 KB

Contents

require 'spec_helper'

describe GunBroker do

  it 'has a VERSION' do
    expect(GunBroker::VERSION).to be_a(String)
  end

  context 'dev_key' do
    let(:key) { 'foo' }

    it 'sets @@dev_key' do
      GunBroker.dev_key = key
      expect(GunBroker.class_variable_get(:@@dev_key)).to eq(key)
    end

    it 'returns @@dev_key' do
      GunBroker.dev_key = key
      expect(GunBroker.dev_key).to eq(key)
    end

    it 'raises an exception if @@dev_key is nil' do
      GunBroker.class_variable_set(:@@dev_key, nil)
      expect { GunBroker.dev_key }.to raise_error(GunBroker::Error)
    end
  end

  context '.time' do
    before(:all) do
      GunBroker.dev_key = 'test-dev-key'
    end

    let(:endpoint) { [GunBroker::API::GUNBROKER_API, '/GunBrokerTime'].join }
    let(:response) { JSON.parse(response_fixture('time')) }

    it 'should return the GunBroker time' do
      stub_request(:get, endpoint)
        .with(headers: headers)
        .to_return(body: response_fixture('time'))

      time = GunBroker.time
      expect(time['gunBrokerTime']).to eq(response['gunBrokerTime'])
      expect(time['gunBrokerVersion']).to eq(response['gunBrokerVersion'])
    end
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
gun_broker-0.4.11 spec/gun_broker_spec.rb
gun_broker-0.4.10 spec/gun_broker_spec.rb
gun_broker-0.4.9 spec/gun_broker_spec.rb
gun_broker-0.4.8 spec/gun_broker_spec.rb
gun_broker-0.4.7 spec/gun_broker_spec.rb
gun_broker-0.4.6 spec/gun_broker_spec.rb