Sha256: 77f8556a735a44ea96babf6c96997355065efb74ed0111fd625b905e9ecee2e7

Contents?: true

Size: 1.82 KB

Versions: 2

Compression:

Stored size: 1.82 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 5
      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

2 entries across 2 versions & 1 rubygems

Version Path
rev-api-2.5.0 spec/lib/rev/get_orders_spec.rb
rev-api-2.3.1 spec/lib/rev/get_orders_spec.rb