Sha256: 65f8fe4664551e185e10231bff850a19adad0f80f103fbc2eb68fb9cf878d421

Contents?: true

Size: 1.75 KB

Versions: 4

Compression:

Stored size: 1.75 KB

Contents

require_relative '../../spec_helper'

describe 'GET /orders' do
  let(:client) { Rev.new('welcome', 'AAAAAu/YjZ3phXU5FsF35yIcgiA=', 'www.revtrunk.com') }

  describe 'GET /orders without page number' do
    it 'must get first page of existing orders' do
      VCR.insert_cassette 'get_orders'

      page = client.get_orders_page

      assert_requested :get, /.*\/api\/v1\/orders\?page=0/, :times => 1

      page.orders.must_be_instance_of Array
      page.results_per_page.must_equal 8
      page.orders.size.must_equal 8
      page.page.must_equal 0
      page.total_count.must_equal 77
    end
  end

  describe 'GET /orders?page={pagenum}' do
    it 'must load any page' do
      VCR.insert_cassette 'get_third_page_of_orders'

      page = client.get_orders_page(2)

      assert_requested :get, /.*\/api\/v1\/orders\?page=2/, :times => 1

      page.orders.size.must_equal 8
      page.page.must_equal 2
      page.orders.first.order_number.must_equal 'TC0229215557'
    end
  end

  describe 'GET /orders without client reference raises' do
    it 'must raise NotAcceptableError' do
      assert_raises(ArgumentError) { client.get_orders_by_client_ref }
    end
  end

  describe 'GET /orders?page=0&clientRef={client_ref}' do
    it 'must load order with given reference id' do
      VCR.insert_cassette 'get_orders_with_clientRef'

      page = client.get_orders_by_client_ref('my ref')

      assert_requested :get, /.*\/api\/v1\/orders\?clientRef=my%20ref&page=0/, :times => 1

      page.orders.must_be_instance_of Array
      page.results_per_page.must_equal 25
      page.orders.size.must_equal 1
      page.page.must_equal 0
      page.total_count.must_equal 1
      page.orders[0].order_number.must_equal 'CP0180436196'
    end
  end

  after do
    VCR.eject_cassette
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rev-api-2.1.0 spec/lib/rev/get_orders_spec.rb
rev-api-2.0.3 spec/lib/rev/get_orders_spec.rb
rev-api-2.0.2 spec/lib/rev/get_orders_spec.rb
rev-api-2.0.1 spec/lib/rev/get_orders_spec.rb