Sha256: 571fe841f3d1029460646344395b159842d8d1a4e78f924819b5f29d6a2b6d0a

Contents?: true

Size: 1.7 KB

Versions: 1

Compression:

Stored size: 1.7 KB

Contents

require 'spec_helper'

describe Privateer::Connection do
  let(:connection) { Privateer::Connection.new(VALID_OPTIONS) }

  describe '.new' do
    it 'accepts valid options' do
      connection.must_be_instance_of Privateer::Connection
    end

    it 'raises ArgumentError on missing store_name' do
      lambda {
        Privateer::Connection.new(api_key: 'testkey', password: 'secret')
      }.must_raise ArgumentError
    end

    it 'raises ArgumentError on missing api_key' do
      lambda {
        Privateer::Connection.new(store_name: 'test', password: 'secret')
      }.must_raise ArgumentError
    end

    it 'raises ArgumentError on missing password' do
      lambda {
        Privateer::Connection.new(store_name: 'test', api_key: 'testkey')
      }.must_raise ArgumentError
    end
  end

  describe '#get' do
    it 'raises Argument Error on missing target' do
      lambda {
        connection.get
      }.must_raise ArgumentError
    end

    it 'accepts parameters' do
      connection.get('products', {collection_id: 1})
    end

    it 'returns a valid response' do
      code, body, resp = connection.get('products')
      code.must_equal 200
      body.wont_be_nil
      resp.must_be_instance_of Faraday::Response
    end
  end

  describe '#post' do
    it 'raises Argument Error on missing target' do
      lambda {
        connection.post
      }.must_raise ArgumentError
    end
  end

  describe '#put' do
    it 'raises Argument Error on missing target' do
      lambda {
        connection.put
      }.must_raise ArgumentError
    end
  end

  describe '#delete' do
    it 'raises Argument Error on missing target' do
      lambda {
        connection.delete
      }.must_raise ArgumentError
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
privateer-0.0.1 spec/connection_spec.rb