rev-api 2.3.0 → 2.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +22 -22
  3. data/.ruby-gemset +1 -1
  4. data/.ruby-version +1 -1
  5. data/.travis.yml +8 -8
  6. data/Gemfile +3 -3
  7. data/LICENSE +191 -191
  8. data/README.md +131 -131
  9. data/Rakefile +13 -13
  10. data/examples/cli.rb +270 -270
  11. data/lib/rev-api.rb +26 -26
  12. data/lib/rev-api/api.rb +326 -326
  13. data/lib/rev-api/api_serializable.rb +30 -30
  14. data/lib/rev-api/exceptions.rb +97 -97
  15. data/lib/rev-api/http_client.rb +97 -97
  16. data/lib/rev-api/models/order.rb +129 -130
  17. data/lib/rev-api/models/order_request.rb +276 -276
  18. data/lib/rev-api/version.rb +3 -3
  19. data/rev-api.gemspec +33 -33
  20. data/spec/fixtures/api_cassettes/cancel_order.yml +38 -38
  21. data/spec/fixtures/api_cassettes/cancel_order_not_allowed.yml +40 -40
  22. data/spec/fixtures/api_cassettes/get_attachment_content.yml +399 -399
  23. data/spec/fixtures/api_cassettes/get_attachment_content_as_pdf.yml +399 -399
  24. data/spec/fixtures/api_cassettes/get_attachment_content_as_text.yml +65 -65
  25. data/spec/fixtures/api_cassettes/get_attachment_content_as_youtube_transcript.yml +66 -66
  26. data/spec/fixtures/api_cassettes/get_attachment_content_unacceptable_representation.yml +42 -42
  27. data/spec/fixtures/api_cassettes/get_attachment_content_with_invalid_id.yml +42 -42
  28. data/spec/fixtures/api_cassettes/get_attachment_metadata.yml +42 -42
  29. data/spec/fixtures/api_cassettes/get_attachment_with_invalid_id.yml +40 -40
  30. data/spec/fixtures/api_cassettes/get_orders.yml +122 -122
  31. data/spec/fixtures/api_cassettes/get_orders_with_clientRef.yml +41 -41
  32. data/spec/fixtures/api_cassettes/get_tc_order.yml +44 -44
  33. data/spec/fixtures/api_cassettes/get_third_page_of_orders.yml +52 -52
  34. data/spec/fixtures/api_cassettes/link_input.yml +44 -44
  35. data/spec/fixtures/api_cassettes/link_input_with_all_attributes.yml +44 -44
  36. data/spec/fixtures/api_cassettes/link_input_with_spaces_in_filename.yml +45 -45
  37. data/spec/fixtures/api_cassettes/not_found_order.yml +42 -42
  38. data/spec/fixtures/api_cassettes/submit_cp_order.yml +45 -45
  39. data/spec/fixtures/api_cassettes/submit_su_order.yml +45 -45
  40. data/spec/fixtures/api_cassettes/submit_tc_order_with_account_balance.yml +45 -45
  41. data/spec/fixtures/api_cassettes/submit_tc_order_with_invalid_request.yml +45 -45
  42. data/spec/fixtures/api_cassettes/submit_tc_order_without_specifying_payment.yml +45 -45
  43. data/spec/fixtures/api_cassettes/unauthorized.yml +42 -42
  44. data/spec/fixtures/api_cassettes/upload_input.yml +90 -90
  45. data/spec/fixtures/api_cassettes/upload_input_with_invalid_content_type.yml +91 -91
  46. data/spec/lib/rev/api_spec.rb +24 -24
  47. data/spec/lib/rev/cancel_order_spec.rb +24 -24
  48. data/spec/lib/rev/exceptions_spec.rb +8 -8
  49. data/spec/lib/rev/get_attachment_content_spec.rb +79 -79
  50. data/spec/lib/rev/get_attachment_metadata_spec.rb +33 -33
  51. data/spec/lib/rev/get_order_spec.rb +52 -52
  52. data/spec/lib/rev/get_orders_spec.rb +62 -62
  53. data/spec/lib/rev/http_client_spec.rb +32 -32
  54. data/spec/lib/rev/models/order_spec.rb +58 -58
  55. data/spec/lib/rev/post_inputs_spec.rb +94 -94
  56. data/spec/lib/rev/post_order_spec.rb +163 -163
  57. data/spec/spec_helper.rb +47 -47
  58. data/spec/test_helpers.rb +5 -5
  59. metadata +36 -78
@@ -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
+ describe 'must save binary content to file' do
18
+ it 'when no representation given' do
19
+ VCR.insert_cassette 'get_attachment_content'
20
+ # we just save mocked binary response body to file and check for existence
21
+ client.save_attachment_content('4QWoFrwBAAABAAAA', filename) # from order TC0380110305
22
+ File.file?(filename).must_equal true
23
+
24
+ assert_requested :get, /.*\/api\/v1\/attachments\/4QWoFrwBAAABAAAA\/content/, :times => 1
25
+ end
26
+
27
+ it 'using given correct representation' do
28
+ VCR.insert_cassette 'get_attachment_content_as_pdf'
29
+
30
+ client.save_attachment_content('4QWoFrwBAAABAAAA', filename, Rev::Attachment::REPRESENTATIONS[:pdf])
31
+ File.file?(filename).must_equal true
32
+ # we don't actually check whether it's PDF - we assume it is. We just supply headers as requested
33
+ end
34
+ end
35
+
36
+ it 'must specify Accept-Charset header for plain text' do
37
+ VCR.insert_cassette 'get_attachment_content_as_text'
38
+
39
+ client.save_attachment_content('4QWoFrwBAAABAAAA', filename, Rev::Attachment::REPRESENTATIONS[:txt])
40
+
41
+ assert_requested :get, /.*\/api\/v1\/attachments\/4QWoFrwBAAABAAAA\/content/, :times => 1 do |req|
42
+ req.headers['Accept-Charset'].must_equal 'utf-8'
43
+ end
44
+ end
45
+
46
+ it 'must specify Accept-Charset header for youtube transcript' do
47
+ VCR.insert_cassette 'get_attachment_content_as_youtube_transcript'
48
+
49
+ client.save_attachment_content('4QWoFrwBAAABAAAA', filename, Rev::Attachment::REPRESENTATIONS[:youtube])
50
+
51
+ assert_requested :get, /.*\/api\/v1\/attachments\/4QWoFrwBAAABAAAA\/content/, :times => 1 do |req|
52
+ req.headers['Accept-Charset'].must_equal 'utf-8'
53
+ end
54
+ end
55
+ end
56
+
57
+ describe 'raise exception on failure' do
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 to .doc
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, 'application/msword') }
70
+ action.must_raise Rev::NotAcceptableError
71
+ end
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,52 +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
- after do
50
- VCR.eject_cassette
51
- end
52
- 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 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
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