rev-api 2.2.0 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/.coveralls.yml +1 -1
  3. data/.gitignore +21 -21
  4. data/.ruby-gemset +1 -1
  5. data/.ruby-version +1 -1
  6. data/.travis.yml +8 -8
  7. data/Gemfile +3 -3
  8. data/LICENSE +191 -191
  9. data/README.md +132 -132
  10. data/Rakefile +13 -13
  11. data/examples/cli.rb +270 -270
  12. data/lib/rev-api.rb +25 -25
  13. data/lib/rev-api/api.rb +326 -326
  14. data/lib/rev-api/api_serializable.rb +30 -30
  15. data/lib/rev-api/exceptions.rb +97 -100
  16. data/lib/rev-api/http_client.rb +97 -97
  17. data/lib/rev-api/models/order.rb +130 -138
  18. data/lib/rev-api/models/order_request.rb +194 -222
  19. data/lib/rev-api/version.rb +3 -3
  20. data/rev-api.gemspec +34 -34
  21. data/spec/fixtures/api_cassettes/cancel_order.yml +38 -38
  22. data/spec/fixtures/api_cassettes/cancel_order_not_allowed.yml +40 -40
  23. data/spec/fixtures/api_cassettes/get_attachment_content.yml +399 -399
  24. data/spec/fixtures/api_cassettes/get_attachment_content_as_pdf.yml +399 -399
  25. data/spec/fixtures/api_cassettes/get_attachment_content_as_text.yml +65 -65
  26. data/spec/fixtures/api_cassettes/get_attachment_content_as_youtube_transcript.yml +66 -66
  27. data/spec/fixtures/api_cassettes/get_attachment_content_unacceptable_representation.yml +42 -42
  28. data/spec/fixtures/api_cassettes/get_attachment_content_with_invalid_id.yml +42 -42
  29. data/spec/fixtures/api_cassettes/get_attachment_metadata.yml +42 -42
  30. data/spec/fixtures/api_cassettes/get_attachment_with_invalid_id.yml +40 -40
  31. data/spec/fixtures/api_cassettes/get_orders.yml +122 -122
  32. data/spec/fixtures/api_cassettes/get_orders_with_clientRef.yml +41 -41
  33. data/spec/fixtures/api_cassettes/get_tc_order.yml +44 -44
  34. data/spec/fixtures/api_cassettes/get_third_page_of_orders.yml +52 -58
  35. data/spec/fixtures/api_cassettes/link_input.yml +44 -44
  36. data/spec/fixtures/api_cassettes/link_input_with_all_attributes.yml +44 -44
  37. data/spec/fixtures/api_cassettes/link_input_with_spaces_in_filename.yml +45 -45
  38. data/spec/fixtures/api_cassettes/not_found_order.yml +42 -42
  39. data/spec/fixtures/api_cassettes/submit_cp_order.yml +45 -45
  40. data/spec/fixtures/api_cassettes/submit_su_order.yml +45 -45
  41. data/spec/fixtures/api_cassettes/submit_tc_order_with_account_balance.yml +45 -45
  42. data/spec/fixtures/api_cassettes/submit_tc_order_with_invalid_request.yml +45 -45
  43. data/spec/fixtures/api_cassettes/submit_tc_order_without_specifying_payment.yml +45 -45
  44. data/spec/fixtures/api_cassettes/unauthorized.yml +42 -42
  45. data/spec/fixtures/api_cassettes/upload_input.yml +90 -90
  46. data/spec/fixtures/api_cassettes/upload_input_with_invalid_content_type.yml +91 -91
  47. data/spec/lib/rev/api_spec.rb +24 -24
  48. data/spec/lib/rev/cancel_order_spec.rb +24 -24
  49. data/spec/lib/rev/exceptions_spec.rb +8 -8
  50. data/spec/lib/rev/get_attachment_content_spec.rb +79 -79
  51. data/spec/lib/rev/get_attachment_metadata_spec.rb +33 -33
  52. data/spec/lib/rev/get_order_spec.rb +52 -68
  53. data/spec/lib/rev/get_orders_spec.rb +62 -62
  54. data/spec/lib/rev/http_client_spec.rb +32 -32
  55. data/spec/lib/rev/models/order_request_spec.rb +0 -7
  56. data/spec/lib/rev/models/order_spec.rb +58 -58
  57. data/spec/lib/rev/post_inputs_spec.rb +94 -94
  58. data/spec/lib/rev/post_order_spec.rb +163 -195
  59. data/spec/spec_helper.rb +49 -49
  60. metadata +38 -41
  61. data/spec/fixtures/api_cassettes/get_tr_order.yml +0 -44
  62. data/spec/fixtures/api_cassettes/submit_tr_order.yml +0 -44
@@ -1,25 +1,25 @@
1
- require_relative '../../spec_helper'
2
-
3
- describe 'POST /orders/{order_num}/cancel' do
4
- let(:client) { Rev.new('welcome', 'AAAAAu/YjZ3phXU5FsF35yIcgiA=', 'www.revtrunk.com') }
5
-
6
- it 'must cancel order' do
7
- VCR.insert_cassette 'cancel_order'
8
-
9
- client.cancel_order('TC0166192942').must_equal true
10
-
11
- assert_requested :post, /.*\/api\/v1\/orders\/TC0166192942\/cancel/, :times => 1,
12
- :body => { :order_num => 'TC0166192942' }
13
- end
14
-
15
- it 'must raise ForbiddenError when cancellation is not allowed' do
16
- VCR.insert_cassette 'cancel_order_not_allowed'
17
-
18
- action = lambda { client.cancel_order('TC0367111289') }
19
- action.must_raise Rev::ForbiddenError
20
- end
21
-
22
- after do
23
- VCR.eject_cassette
24
- end
1
+ require_relative '../../spec_helper'
2
+
3
+ describe 'POST /orders/{order_num}/cancel' do
4
+ let(:client) { Rev.new('welcome', 'AAAAAu/YjZ3phXU5FsF35yIcgiA=', 'www.revtrunk.com') }
5
+
6
+ it 'must cancel order' do
7
+ VCR.insert_cassette 'cancel_order'
8
+
9
+ client.cancel_order('TC0166192942').must_equal true
10
+
11
+ assert_requested :post, /.*\/api\/v1\/orders\/TC0166192942\/cancel/, :times => 1,
12
+ :body => { :order_num => 'TC0166192942' }
13
+ end
14
+
15
+ it 'must raise ForbiddenError when cancellation is not allowed' do
16
+ VCR.insert_cassette 'cancel_order_not_allowed'
17
+
18
+ action = lambda { client.cancel_order('TC0367111289') }
19
+ action.must_raise Rev::ForbiddenError
20
+ end
21
+
22
+ after do
23
+ VCR.eject_cassette
24
+ end
25
25
  end
@@ -1,8 +1,8 @@
1
- require_relative '../../spec_helper'
2
-
3
- describe 'Exceptions' do
4
- it 'has INVALID_MEDIA_LENGTH' do
5
- Rev::OrderRequestErrorCodes::INVALID_MEDIA_LENGTH.must_equal Rev::OrderRequestErrorCodes::INVALID_AUDIO_LENGTH
6
- end
7
- end
8
-
1
+ require_relative '../../spec_helper'
2
+
3
+ describe 'Exceptions' do
4
+ it 'has INVALID_MEDIA_LENGTH' do
5
+ Rev::OrderRequestErrorCodes::INVALID_MEDIA_LENGTH.must_equal Rev::OrderRequestErrorCodes::INVALID_AUDIO_LENGTH
6
+ end
7
+ end
8
+
@@ -1,79 +1,79 @@
1
- require_relative '../../spec_helper'
2
-
3
- describe 'GET /attachments/{id}/content' do
4
- let(:client) { Rev.new('welcome', 'AAAAAu/YjZ3phXU5FsF35yIcgiA=', 'www.revtrunk.com') }
5
-
6
- filename = './spec/tmp_get_attachment_content'
7
-
8
- before do
9
- File.delete filename if File.file? filename # clean before
10
- end
11
-
12
- after do
13
- File.delete filename if File.file? filename # clean after
14
- end
15
-
16
- describe 'success' do
17
-
18
- describe 'must save binary content to file' do
19
- it 'when no representation given' do
20
- VCR.insert_cassette 'get_attachment_content'
21
- # we just save mocked binary response body to file and check for existence
22
- client.save_attachment_content('4QWoFrwBAAABAAAA', filename) # from order TC0380110305
23
- File.file?(filename).must_equal true
24
-
25
- assert_requested :get, /.*\/api\/v1\/attachments\/4QWoFrwBAAABAAAA\/content/, :times => 1
26
- end
27
-
28
- it 'using given correct representation' do
29
- VCR.insert_cassette 'get_attachment_content_as_pdf'
30
-
31
- client.save_attachment_content('4QWoFrwBAAABAAAA', filename, Rev::Attachment::REPRESENTATIONS[:pdf])
32
- File.file?(filename).must_equal true
33
- # we don't actually check whether it's PDF - we assume it is. We just supply headers as requested
34
- end
35
- end
36
-
37
- it 'must specify Accept-Charset header for plain text' do
38
- VCR.insert_cassette 'get_attachment_content_as_text'
39
-
40
- client.save_attachment_content('4QWoFrwBAAABAAAA', filename, Rev::Attachment::REPRESENTATIONS[:txt])
41
-
42
- assert_requested :get, /.*\/api\/v1\/attachments\/4QWoFrwBAAABAAAA\/content/, :times => 1 do |req|
43
- req.headers['Accept-Charset'].must_equal 'utf-8'
44
- end
45
- end
46
-
47
- it 'must specify Accept-Charset header for youtube transcript' do
48
- VCR.insert_cassette 'get_attachment_content_as_youtube_transcript'
49
-
50
- client.save_attachment_content('4QWoFrwBAAABAAAA', filename, Rev::Attachment::REPRESENTATIONS[:youtube])
51
-
52
- assert_requested :get, /.*\/api\/v1\/attachments\/4QWoFrwBAAABAAAA\/content/, :times => 1 do |req|
53
- req.headers['Accept-Charset'].must_equal 'utf-8'
54
- end
55
- end
56
- end
57
-
58
- it 'must raise NotFoundError when attachment id is invalid' do
59
- VCR.insert_cassette 'get_attachment_content_with_invalid_id'
60
-
61
- action = lambda { client.save_attachment_content('trololo', filename) }
62
- action.must_raise Rev::NotFoundError
63
- end
64
-
65
- # requesting conversion from pdf to :docx from order TC0263917003
66
- it 'must raise NotAcceptableError when requested representation is not supported by API' do
67
- VCR.insert_cassette 'get_attachment_content_unacceptable_representation'
68
-
69
- action = lambda { client.save_attachment_content('yw27D3gCAAABAAAA', filename,
70
- Rev::Attachment::REPRESENTATIONS[:docx]) }
71
- action.must_raise Rev::NotAcceptableError
72
- end
73
-
74
- after do
75
- VCR.eject_cassette
76
- end
77
- end
78
-
79
-
1
+ require_relative '../../spec_helper'
2
+
3
+ describe 'GET /attachments/{id}/content' do
4
+ let(:client) { Rev.new('welcome', 'AAAAAu/YjZ3phXU5FsF35yIcgiA=', 'www.revtrunk.com') }
5
+
6
+ filename = './spec/tmp_get_attachment_content'
7
+
8
+ before do
9
+ File.delete filename if File.file? filename # clean before
10
+ end
11
+
12
+ after do
13
+ File.delete filename if File.file? filename # clean after
14
+ end
15
+
16
+ describe 'success' do
17
+
18
+ describe 'must save binary content to file' do
19
+ it 'when no representation given' do
20
+ VCR.insert_cassette 'get_attachment_content'
21
+ # we just save mocked binary response body to file and check for existence
22
+ client.save_attachment_content('4QWoFrwBAAABAAAA', filename) # from order TC0380110305
23
+ File.file?(filename).must_equal true
24
+
25
+ assert_requested :get, /.*\/api\/v1\/attachments\/4QWoFrwBAAABAAAA\/content/, :times => 1
26
+ end
27
+
28
+ it 'using given correct representation' do
29
+ VCR.insert_cassette 'get_attachment_content_as_pdf'
30
+
31
+ client.save_attachment_content('4QWoFrwBAAABAAAA', filename, Rev::Attachment::REPRESENTATIONS[:pdf])
32
+ File.file?(filename).must_equal true
33
+ # we don't actually check whether it's PDF - we assume it is. We just supply headers as requested
34
+ end
35
+ end
36
+
37
+ it 'must specify Accept-Charset header for plain text' do
38
+ VCR.insert_cassette 'get_attachment_content_as_text'
39
+
40
+ client.save_attachment_content('4QWoFrwBAAABAAAA', filename, Rev::Attachment::REPRESENTATIONS[:txt])
41
+
42
+ assert_requested :get, /.*\/api\/v1\/attachments\/4QWoFrwBAAABAAAA\/content/, :times => 1 do |req|
43
+ req.headers['Accept-Charset'].must_equal 'utf-8'
44
+ end
45
+ end
46
+
47
+ it 'must specify Accept-Charset header for youtube transcript' do
48
+ VCR.insert_cassette 'get_attachment_content_as_youtube_transcript'
49
+
50
+ client.save_attachment_content('4QWoFrwBAAABAAAA', filename, Rev::Attachment::REPRESENTATIONS[:youtube])
51
+
52
+ assert_requested :get, /.*\/api\/v1\/attachments\/4QWoFrwBAAABAAAA\/content/, :times => 1 do |req|
53
+ req.headers['Accept-Charset'].must_equal 'utf-8'
54
+ end
55
+ end
56
+ end
57
+
58
+ it 'must raise NotFoundError when attachment id is invalid' do
59
+ VCR.insert_cassette 'get_attachment_content_with_invalid_id'
60
+
61
+ action = lambda { client.save_attachment_content('trololo', filename) }
62
+ action.must_raise Rev::NotFoundError
63
+ end
64
+
65
+ # requesting conversion from pdf to :docx from order TC0263917003
66
+ it 'must raise NotAcceptableError when requested representation is not supported by API' do
67
+ VCR.insert_cassette 'get_attachment_content_unacceptable_representation'
68
+
69
+ action = lambda { client.save_attachment_content('yw27D3gCAAABAAAA', filename,
70
+ Rev::Attachment::REPRESENTATIONS[:docx]) }
71
+ action.must_raise Rev::NotAcceptableError
72
+ end
73
+
74
+ after do
75
+ VCR.eject_cassette
76
+ end
77
+ end
78
+
79
+
@@ -1,33 +1,33 @@
1
- require_relative '../../spec_helper'
2
-
3
- describe 'GET /attachments/{id}' do
4
- let(:client) { Rev.new('welcome', 'AAAAAu/YjZ3phXU5FsF35yIcgiA=', 'www.revtrunk.com') }
5
-
6
- it 'must retrieve metadata' do
7
- VCR.insert_cassette 'get_attachment_metadata'
8
-
9
- attachment = client.get_attachment_metadata('LufnCVQCAAAAAAAA')
10
-
11
- assert_requested :get, /.*\/api\/v1\/attachments\/LufnCVQCAAAAAAAA/, :times => 1
12
-
13
- attachment.id.must_equal 'LufnCVQCAAAAAAAA'
14
- attachment.name.must_equal 'How can I find success in life.mp4'
15
- attachment.kind.must_equal 'media'
16
- attachment.audio_length_seconds.must_equal 300
17
- attachment.links.must_be_instance_of Array
18
- attachment.links.size.must_equal 1
19
- attachment.links.first.rel.must_equal 'content'
20
- attachment.links.first.href.must_equal 'https://www.revtrunk.com/api/v1/attachments/LufnCVQCAAAAAAAA/content'
21
- end
22
-
23
- it 'must raise NotFoundError when attachment id is invalid' do
24
- VCR.insert_cassette 'get_attachment_with_invalid_id'
25
-
26
- action = lambda { client.get_attachment_metadata('trololo') }
27
- action.must_raise Rev::NotFoundError
28
- end
29
-
30
- after do
31
- VCR.eject_cassette
32
- end
33
- end
1
+ require_relative '../../spec_helper'
2
+
3
+ describe 'GET /attachments/{id}' do
4
+ let(:client) { Rev.new('welcome', 'AAAAAu/YjZ3phXU5FsF35yIcgiA=', 'www.revtrunk.com') }
5
+
6
+ it 'must retrieve metadata' do
7
+ VCR.insert_cassette 'get_attachment_metadata'
8
+
9
+ attachment = client.get_attachment_metadata('LufnCVQCAAAAAAAA')
10
+
11
+ assert_requested :get, /.*\/api\/v1\/attachments\/LufnCVQCAAAAAAAA/, :times => 1
12
+
13
+ attachment.id.must_equal 'LufnCVQCAAAAAAAA'
14
+ attachment.name.must_equal 'How can I find success in life.mp4'
15
+ attachment.kind.must_equal 'media'
16
+ attachment.audio_length_seconds.must_equal 300
17
+ attachment.links.must_be_instance_of Array
18
+ attachment.links.size.must_equal 1
19
+ attachment.links.first.rel.must_equal 'content'
20
+ attachment.links.first.href.must_equal 'https://www.revtrunk.com/api/v1/attachments/LufnCVQCAAAAAAAA/content'
21
+ end
22
+
23
+ it 'must raise NotFoundError when attachment id is invalid' do
24
+ VCR.insert_cassette 'get_attachment_with_invalid_id'
25
+
26
+ action = lambda { client.get_attachment_metadata('trololo') }
27
+ action.must_raise Rev::NotFoundError
28
+ end
29
+
30
+ after do
31
+ VCR.eject_cassette
32
+ end
33
+ end
@@ -1,68 +1,52 @@
1
- require_relative '../../spec_helper'
2
-
3
- describe 'GET /orders/{order_num}' do
4
- let(:client) { Rev.new('welcome', 'AAAAAu/YjZ3phXU5FsF35yIcgiA=', 'www.revtrunk.com') }
5
-
6
- describe 'Transcription' do
7
- before do
8
- VCR.insert_cassette 'get_tc_order'
9
- end
10
-
11
- it 'must get an order by given order number' do
12
- client.get_order('TC0233908691').wont_be_nil
13
-
14
- assert_requested :get, /.*\/api\/v1\/orders\/TC0233908691/, :times => 1
15
- end
16
-
17
- describe 'loaded order' do
18
- let(:order) { client.get_order('TC0233908691') }
19
-
20
- it 'must have basic attributes' do
21
- order.order_number.must_equal 'TC0233908691'
22
- order.price.must_equal 10.0
23
- order.status.must_equal 'Finding Transcriptionist'
24
- order.client_ref.must_equal 'XC123'
25
- end
26
-
27
- it 'must have comments' do
28
- order.comments.size.must_equal 1
29
- order.comments.first.by.must_equal 'Admin Admin'
30
- order.comments.first.text.must_be_empty
31
- order.comments.first.timestamp.day.must_equal 6
32
- order.comments.first.timestamp.month.must_equal 9
33
- order.comments.first.timestamp.year.must_equal 2013
34
- end
35
-
36
- it 'must have attachments' do
37
- order.attachments.size.must_equal 1
38
- order.attachments.first.kind.must_equal 'media'
39
- end
40
-
41
- it 'must have transcription info' do
42
- order.transcription.total_length_seconds.must_equal 600
43
- order.transcription.verbatim.must_equal false
44
- order.transcription.timestamps.must_equal false
45
- end
46
- end
47
- end
48
-
49
- describe 'Translation' do
50
- before do
51
- VCR.insert_cassette 'get_tr_order'
52
- end
53
-
54
- describe 'loaded order' do
55
- let(:order) { client.get_order('TR0116711100') }
56
-
57
- it 'must have translation info' do
58
- order.translation.total_word_count.must_equal 2
59
- order.translation.source_language_code.must_equal 'cs'
60
- order.translation.destination_language_code.must_equal 'en'
61
- end
62
- end
63
- end
64
-
65
- after do
66
- VCR.eject_cassette
67
- end
68
- end
1
+ require_relative '../../spec_helper'
2
+
3
+ describe 'GET /orders/{order_num}' do
4
+ let(:client) { Rev.new('welcome', 'AAAAAu/YjZ3phXU5FsF35yIcgiA=', 'www.revtrunk.com') }
5
+
6
+ describe 'Transcription' do
7
+ before do
8
+ VCR.insert_cassette 'get_tc_order'
9
+ end
10
+
11
+ it 'must get an order by given order number' do
12
+ client.get_order('TC0233908691').wont_be_nil
13
+
14
+ assert_requested :get, /.*\/api\/v1\/orders\/TC0233908691/, :times => 1
15
+ end
16
+
17
+ describe 'loaded order' do
18
+ let(:order) { client.get_order('TC0233908691') }
19
+
20
+ it 'must have basic attributes' do
21
+ order.order_number.must_equal 'TC0233908691'
22
+ order.price.must_equal 10.0
23
+ order.status.must_equal 'Finding Transcriptionist'
24
+ order.client_ref.must_equal 'XC123'
25
+ end
26
+
27
+ it 'must have comments' do
28
+ order.comments.size.must_equal 1
29
+ order.comments.first.by.must_equal 'Admin Admin'
30
+ order.comments.first.text.must_be_empty
31
+ order.comments.first.timestamp.day.must_equal 6
32
+ order.comments.first.timestamp.month.must_equal 9
33
+ order.comments.first.timestamp.year.must_equal 2013
34
+ end
35
+
36
+ it 'must have attachments' do
37
+ order.attachments.size.must_equal 1
38
+ order.attachments.first.kind.must_equal 'media'
39
+ end
40
+
41
+ it 'must have transcription info' do
42
+ order.transcription.total_length_seconds.must_equal 600
43
+ order.transcription.verbatim.must_equal false
44
+ order.transcription.timestamps.must_equal false
45
+ end
46
+ end
47
+ end
48
+
49
+ after do
50
+ VCR.eject_cassette
51
+ end
52
+ end
@@ -1,62 +1,62 @@
1
- require_relative '../../spec_helper'
2
-
3
- describe 'GET /orders' do
4
- let(:client) { Rev.new('welcome', 'AAAAAu/YjZ3phXU5FsF35yIcgiA=', 'www.revtrunk.com') }
5
-
6
- describe 'GET /orders without page number' do
7
- it 'must get first page of existing orders' do
8
- VCR.insert_cassette 'get_orders'
9
-
10
- page = client.get_orders_page
11
-
12
- assert_requested :get, /.*\/api\/v1\/orders\?page=0/, :times => 1
13
-
14
- page.orders.must_be_instance_of Array
15
- page.results_per_page.must_equal 8
16
- page.orders.size.must_equal 8
17
- page.page.must_equal 0
18
- page.total_count.must_equal 77
19
- end
20
- end
21
-
22
- describe 'GET /orders?page={pagenum}' do
23
- it 'must load any page' do
24
- VCR.insert_cassette 'get_third_page_of_orders'
25
-
26
- page = client.get_orders_page(2)
27
-
28
- assert_requested :get, /.*\/api\/v1\/orders\?page=2/, :times => 1
29
-
30
- page.orders.size.must_equal 8
31
- page.page.must_equal 2
32
- page.orders.first.order_number.must_equal 'TC0229215557'
33
- end
34
- end
35
-
36
- describe 'GET /orders without client reference raises' do
37
- it 'must raise NotAcceptableError' do
38
- assert_raises(ArgumentError) { client.get_orders_by_client_ref }
39
- end
40
- end
41
-
42
- describe 'GET /orders?page=0&clientRef={client_ref}' do
43
- it 'must load order with given reference id' do
44
- VCR.insert_cassette 'get_orders_with_clientRef'
45
-
46
- page = client.get_orders_by_client_ref('my ref')
47
-
48
- assert_requested :get, /.*\/api\/v1\/orders\?clientRef=my%20ref&page=0/, :times => 1
49
-
50
- page.orders.must_be_instance_of Array
51
- page.results_per_page.must_equal 25
52
- page.orders.size.must_equal 1
53
- page.page.must_equal 0
54
- page.total_count.must_equal 1
55
- page.orders[0].order_number.must_equal 'CP0180436196'
56
- end
57
- end
58
-
59
- after do
60
- VCR.eject_cassette
61
- end
62
- end
1
+ require_relative '../../spec_helper'
2
+
3
+ describe 'GET /orders' do
4
+ let(:client) { Rev.new('welcome', 'AAAAAu/YjZ3phXU5FsF35yIcgiA=', 'www.revtrunk.com') }
5
+
6
+ describe 'GET /orders without page number' do
7
+ it 'must get first page of existing orders' do
8
+ VCR.insert_cassette 'get_orders'
9
+
10
+ page = client.get_orders_page
11
+
12
+ assert_requested :get, /.*\/api\/v1\/orders\?page=0/, :times => 1
13
+
14
+ page.orders.must_be_instance_of Array
15
+ page.results_per_page.must_equal 8
16
+ page.orders.size.must_equal 8
17
+ page.page.must_equal 0
18
+ page.total_count.must_equal 77
19
+ end
20
+ end
21
+
22
+ describe 'GET /orders?page={pagenum}' do
23
+ it 'must load any page' do
24
+ VCR.insert_cassette 'get_third_page_of_orders'
25
+
26
+ page = client.get_orders_page(2)
27
+
28
+ assert_requested :get, /.*\/api\/v1\/orders\?page=2/, :times => 1
29
+
30
+ page.orders.size.must_equal 5
31
+ page.page.must_equal 2
32
+ page.orders.first.order_number.must_equal 'TC0229215557'
33
+ end
34
+ end
35
+
36
+ describe 'GET /orders without client reference raises' do
37
+ it 'must raise NotAcceptableError' do
38
+ assert_raises(ArgumentError) { client.get_orders_by_client_ref }
39
+ end
40
+ end
41
+
42
+ describe 'GET /orders?page=0&clientRef={client_ref}' do
43
+ it 'must load order with given reference id' do
44
+ VCR.insert_cassette 'get_orders_with_clientRef'
45
+
46
+ page = client.get_orders_by_client_ref('my ref')
47
+
48
+ assert_requested :get, /.*\/api\/v1\/orders\?clientRef=my%20ref&page=0/, :times => 1
49
+
50
+ page.orders.must_be_instance_of Array
51
+ page.results_per_page.must_equal 25
52
+ page.orders.size.must_equal 1
53
+ page.page.must_equal 0
54
+ page.total_count.must_equal 1
55
+ page.orders[0].order_number.must_equal 'CP0180436196'
56
+ end
57
+ end
58
+
59
+ after do
60
+ VCR.eject_cassette
61
+ end
62
+ end