bigcommerce 0.10.0 → 1.0.0.beta

Sign up to get free protection for your applications and to get access to all the features.
Files changed (162) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +17 -0
  3. data/.rspec +2 -0
  4. data/.rubocop.yml +620 -0
  5. data/.travis.yml +15 -0
  6. data/CHANGELOG.md +11 -0
  7. data/CONTRIBUTING.md +119 -0
  8. data/DEPENDENCIES.md +7 -0
  9. data/Gemfile +15 -0
  10. data/Guardfile +22 -0
  11. data/LICENSE +15 -15
  12. data/README.md +61 -70
  13. data/RELEASING.md +64 -0
  14. data/Rakefile +8 -6
  15. data/bigcommerce.gemspec +22 -53
  16. data/examples/README.md +148 -0
  17. data/examples/configuration/legacy_auth.rb +12 -0
  18. data/examples/configuration/oauth.rb +9 -0
  19. data/examples/content/blog_post.rb +39 -0
  20. data/examples/content/blog_tag.rb +10 -0
  21. data/examples/content/redirect.rb +43 -0
  22. data/examples/customers/customer.rb +36 -0
  23. data/examples/customers/customer_address.rb +50 -0
  24. data/examples/customers/customer_group.rb +35 -0
  25. data/examples/exception_handling.rb +50 -0
  26. data/examples/geography/country.rb +16 -0
  27. data/examples/geography/state.rb +19 -0
  28. data/examples/marketing/coupon.rb +44 -0
  29. data/examples/orders/order.rb +53 -0
  30. data/examples/orders/order_coupon.rb +17 -0
  31. data/examples/orders/order_message.rb +17 -0
  32. data/examples/orders/order_product.rb +23 -0
  33. data/examples/orders/order_shipping_address.rb +23 -0
  34. data/examples/orders/order_status.rb +15 -0
  35. data/examples/orders/order_tax.rb +17 -0
  36. data/examples/orders/shipment.rb +57 -0
  37. data/examples/payments/payment_method.rb +10 -0
  38. data/examples/products/brand.rb +36 -0
  39. data/examples/products/bulk_pricing_rule.rb +47 -0
  40. data/examples/products/category.rb +37 -0
  41. data/examples/products/configurable_field.rb +29 -0
  42. data/examples/products/custom_field.rb +44 -0
  43. data/examples/products/google_product_search_mapping.rb +12 -0
  44. data/examples/products/option.rb +37 -0
  45. data/examples/products/option_set.rb +35 -0
  46. data/examples/products/option_set_option.rb +50 -0
  47. data/examples/products/option_value.rb +43 -0
  48. data/examples/products/product.rb +44 -0
  49. data/examples/products/product_image.rb +42 -0
  50. data/examples/products/product_option.rb +17 -0
  51. data/examples/products/product_review.rb +12 -0
  52. data/examples/products/product_rule.rb +54 -0
  53. data/examples/products/product_video.rb +45 -0
  54. data/examples/products/sku.rb +48 -0
  55. data/examples/shipping/shipping_method.rb +13 -0
  56. data/examples/store/store_info.rb +10 -0
  57. data/examples/system/time.rb +10 -0
  58. data/examples/tax/tax_class.rb +13 -0
  59. data/examples/webhooks/webhook.rb +29 -0
  60. data/lib/bigcommerce.rb +50 -8
  61. data/lib/bigcommerce/exception.rb +51 -0
  62. data/lib/bigcommerce/middleware/auth.rb +16 -0
  63. data/lib/bigcommerce/middleware/http_exception.rb +14 -0
  64. data/lib/bigcommerce/request.rb +89 -0
  65. data/lib/bigcommerce/resource_actions.rb +51 -0
  66. data/lib/bigcommerce/resources/content/blog_post.rb +31 -0
  67. data/lib/bigcommerce/resources/content/blog_tag.rb +17 -0
  68. data/lib/bigcommerce/resources/content/redirect.rb +21 -0
  69. data/lib/bigcommerce/resources/customers/customer.rb +30 -0
  70. data/lib/bigcommerce/resources/customers/customer_address.rb +34 -0
  71. data/lib/bigcommerce/resources/customers/customer_group.rb +21 -0
  72. data/lib/bigcommerce/resources/geography/country.rb +22 -0
  73. data/lib/bigcommerce/resources/geography/state.rb +25 -0
  74. data/lib/bigcommerce/resources/marketing/coupon.rb +30 -0
  75. data/lib/bigcommerce/resources/orders/order.rb +73 -0
  76. data/lib/bigcommerce/resources/orders/order_coupon.rb +20 -0
  77. data/lib/bigcommerce/resources/orders/order_message.rb +23 -0
  78. data/lib/bigcommerce/resources/orders/order_product.rb +64 -0
  79. data/lib/bigcommerce/resources/orders/order_shipping_address.rb +50 -0
  80. data/lib/bigcommerce/resources/orders/order_status.rb +16 -0
  81. data/lib/bigcommerce/resources/orders/order_tax.rb +23 -0
  82. data/lib/bigcommerce/resources/orders/shipment.rb +30 -0
  83. data/lib/bigcommerce/resources/payments/payment_method.rb +17 -0
  84. data/lib/bigcommerce/resources/products/brand.rb +23 -0
  85. data/lib/bigcommerce/resources/products/bulk_pricing_rule.rb +26 -0
  86. data/lib/bigcommerce/resources/products/category.rb +29 -0
  87. data/lib/bigcommerce/resources/products/configurable_field.rb +30 -0
  88. data/lib/bigcommerce/resources/products/custom_field.rb +24 -0
  89. data/lib/bigcommerce/resources/products/google_product_search_mapping.rb +26 -0
  90. data/lib/bigcommerce/resources/products/option.rb +20 -0
  91. data/lib/bigcommerce/resources/products/option_set.rb +18 -0
  92. data/lib/bigcommerce/resources/products/option_set_option.rb +19 -0
  93. data/lib/bigcommerce/resources/products/option_value.rb +15 -0
  94. data/lib/bigcommerce/resources/products/product.rb +97 -0
  95. data/lib/bigcommerce/resources/products/product_image.rb +31 -0
  96. data/lib/bigcommerce/resources/products/product_option.rb +17 -0
  97. data/lib/bigcommerce/resources/products/product_review.rb +22 -0
  98. data/lib/bigcommerce/resources/products/product_rule.rb +31 -0
  99. data/lib/bigcommerce/resources/products/product_video.rb +24 -0
  100. data/lib/bigcommerce/resources/products/sku.rb +29 -0
  101. data/lib/bigcommerce/resources/resource.rb +10 -0
  102. data/lib/bigcommerce/resources/shipping/shipping_method.rb +15 -0
  103. data/lib/bigcommerce/resources/store/store_information.rb +37 -0
  104. data/lib/bigcommerce/resources/system/time.rb +15 -0
  105. data/lib/bigcommerce/resources/tax/tax_class.rb +15 -0
  106. data/lib/bigcommerce/resources/webhooks/webhook.rb +22 -0
  107. data/lib/bigcommerce/subresource_actions.rb +43 -0
  108. data/lib/bigcommerce/version.rb +1 -4
  109. data/spec/bigcommerce/bigcommerce_spec.rb +76 -0
  110. data/spec/bigcommerce/unit/actions_spec.rb +151 -0
  111. data/spec/bigcommerce/unit/exception_spec.rb +53 -0
  112. data/spec/bigcommerce/unit/middleware/auth_spec.rb +18 -0
  113. data/spec/bigcommerce/unit/middleware/http_exception_spec.rb +40 -0
  114. data/spec/bigcommerce/unit/request_spec.rb +180 -0
  115. data/spec/bigcommerce/unit/resources/content/blog_post_spec.rb +12 -0
  116. data/spec/bigcommerce/unit/resources/content/blog_tag_spec.rb +12 -0
  117. data/spec/bigcommerce/unit/resources/content/redirect_spec.rb +12 -0
  118. data/spec/bigcommerce/unit/resources/customers/customer_address_spec.rb +21 -0
  119. data/spec/bigcommerce/unit/resources/customers/customer_group_spec.rb +12 -0
  120. data/spec/bigcommerce/unit/resources/customers/customer_spec.rb +12 -0
  121. data/spec/bigcommerce/unit/resources/geography/country_spec.rb +12 -0
  122. data/spec/bigcommerce/unit/resources/geography/state_spec.rb +21 -0
  123. data/spec/bigcommerce/unit/resources/marketing/coupon_spec.rb +12 -0
  124. data/spec/bigcommerce/unit/resources/orders/order_product_spec.rb +21 -0
  125. data/spec/bigcommerce/unit/resources/orders/order_shipping_address_spec.rb +21 -0
  126. data/spec/bigcommerce/unit/resources/orders/order_spec.rb +13 -0
  127. data/spec/bigcommerce/unit/resources/orders/shipment_spec.rb +21 -0
  128. data/spec/bigcommerce/unit/resources/payments/payment_method_spec.rb +23 -0
  129. data/spec/bigcommerce/unit/resources/products/brand_spec.rb +12 -0
  130. data/spec/bigcommerce/unit/resources/products/bulk_pricing_rule_spec.rb +21 -0
  131. data/spec/bigcommerce/unit/resources/products/category_spec.rb +12 -0
  132. data/spec/bigcommerce/unit/resources/products/configurable_field_spec.rb +21 -0
  133. data/spec/bigcommerce/unit/resources/products/custom_field_spec.rb +21 -0
  134. data/spec/bigcommerce/unit/resources/products/google_product_search_mapping_spec.rb +14 -0
  135. data/spec/bigcommerce/unit/resources/products/option_set_spec.rb +12 -0
  136. data/spec/bigcommerce/unit/resources/products/option_spec.rb +12 -0
  137. data/spec/bigcommerce/unit/resources/products/product_image_spec.rb +21 -0
  138. data/spec/bigcommerce/unit/resources/products/product_review_spec.rb +14 -0
  139. data/spec/bigcommerce/unit/resources/products/product_rule_spec.rb +21 -0
  140. data/spec/bigcommerce/unit/resources/products/product_spec.rb +13 -0
  141. data/spec/bigcommerce/unit/resources/products/product_video_spec.rb +21 -0
  142. data/spec/bigcommerce/unit/resources/products/sku_spec.rb +21 -0
  143. data/spec/bigcommerce/unit/resources/resource_spec.rb +4 -0
  144. data/spec/bigcommerce/unit/resources/store_info/store_information_spec.rb +12 -0
  145. data/spec/bigcommerce/unit/resources/system/time_spec.rb +12 -0
  146. data/spec/bigcommerce/unit/version_spec.rb +7 -0
  147. data/spec/spec_helper.rb +9 -25
  148. metadata +203 -127
  149. data/lib/big_commerce.rb +0 -1
  150. data/lib/bigcommerce/api.rb +0 -473
  151. data/lib/bigcommerce/connection.rb +0 -171
  152. data/lib/bigcommerce/product.rb +0 -13
  153. data/lib/bigcommerce/resource.rb +0 -50
  154. data/spec/big_commerce_spec.rb +0 -9
  155. data/spec/integration/orders_spec.rb +0 -18
  156. data/spec/support/integration_context.rb +0 -13
  157. data/spec/support/mock_api_context.rb +0 -10
  158. data/spec/unit/api_request_spec.rb +0 -34
  159. data/spec/unit/api_spec.rb +0 -49
  160. data/spec/unit/connection_spec.rb +0 -23
  161. data/spec/unit/date_time_spec.rb +0 -31
  162. data/spec/unit/version_spec.rb +0 -13
@@ -0,0 +1,53 @@
1
+ require 'spec_helper'
2
+
3
+ describe Bigcommerce::HttpErrors do
4
+ let(:dummy_class) { Class.new { extend Bigcommerce::HttpErrors } }
5
+
6
+ it '::ERRORS is not nil' do
7
+ expect(Bigcommerce::HttpErrors::ERRORS).not_to be_nil
8
+ end
9
+
10
+ context 'invalid response status' do
11
+ it 'should throw an exception' do
12
+ code = 404
13
+ expect { dummy_class.throw_http_exception!(code) }.to raise_exception
14
+ end
15
+
16
+ it 'should have a valid error' do
17
+ codes = Bigcommerce::HttpErrors::ERRORS.keys
18
+ codes.each do |code|
19
+ expect { dummy_class.throw_http_exception!(code) }.to raise_exception
20
+ end
21
+ end
22
+
23
+ it 'should allow you to pass in an error message when throwing exception' do
24
+ code = 404
25
+ env = double
26
+ allow(env).to receive(:body) { {} }
27
+ allow(env).to receive(:[]) { {} }
28
+ expect do
29
+ dummy_class.throw_http_exception!(code, env)
30
+ end.to raise_exception(Bigcommerce::HttpErrors::ERRORS[code])
31
+ end
32
+
33
+ it 'should parse out a retry-after header if present' do
34
+ code = 429
35
+ env = double
36
+ allow(env).to receive(:body) { "{\"time\":1426184190}" }
37
+ allow(env).to receive(:[]).with(:response_headers).and_return('X-Retry-After' => 1)
38
+ begin
39
+ dummy_class.throw_http_exception!(code, env)
40
+ rescue Bigcommerce::TooManyRequests => e
41
+ expect(e.response_headers[:retry_after]).to eq 1
42
+ end
43
+ end
44
+ end
45
+
46
+ context 'valid response status' do
47
+ it 'should not throw an exception' do
48
+ code = 200
49
+ env = double
50
+ expect { dummy_class.throw_http_exception!(code, env) }.to_not raise_exception
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe Bigcommerce::Middleware::Auth do
4
+ it 'should set the correct headers' do
5
+ app = double
6
+ options = {
7
+ client_id: 'client_id',
8
+ access_token: 'access_token'
9
+ }
10
+ @api = Bigcommerce::Middleware::Auth.new(app, options)
11
+ expect(app).to receive(:call).with(
12
+ request_headers: {
13
+ 'X-Auth-Client' => 'client_id',
14
+ 'X-Auth-Token' => 'access_token'
15
+ })
16
+ @api.call(request_headers: {})
17
+ end
18
+ end
@@ -0,0 +1,40 @@
1
+ require 'spec_helper'
2
+
3
+ describe Bigcommerce::Middleware::HttpException do
4
+ before(:each) { @e = Bigcommerce::Middleware::HttpException.new }
5
+
6
+ it 'should check for an error on all responses' do
7
+ env = {
8
+ status: '200',
9
+ body: 'Valid'
10
+ }
11
+ expect(@e).to receive(:throw_http_exception!).with(200, env)
12
+ @e.on_complete env
13
+ end
14
+
15
+ context 'when valid response' do
16
+ let(:env) do
17
+ {
18
+ status: '200',
19
+ body: 'Valid'
20
+ }
21
+ end
22
+
23
+ it 'should return its argument if no errors' do
24
+ expect(@e.on_complete(env)).to eq env
25
+ end
26
+ end
27
+
28
+ context 'when invalid response' do
29
+ let(:env) do
30
+ {
31
+ status: '404',
32
+ body: 'Error'
33
+ }
34
+ end
35
+
36
+ it 'should throw an exception' do
37
+ expect { @e.on_complete(env) }.to raise_exception
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,180 @@
1
+ require 'spec_helper'
2
+
3
+ describe Bigcommerce::Request do
4
+ before do
5
+ module Bigcommerce
6
+ class DummyClass
7
+ include Request.new 'foo/%d'
8
+ end
9
+ end
10
+ @klass = Bigcommerce::DummyClass
11
+ end
12
+
13
+ describe '.path' do
14
+ it 'should have a path method to expose the path_builder' do
15
+ expect(@klass.path).to be_kind_of Bigcommerce::PathBuilder
16
+ end
17
+ end
18
+
19
+ describe 'ClassMethods' do
20
+ before do
21
+ double Bigcommerce.api
22
+ end
23
+
24
+ let(:json) { "{\"body\":[{\"time\":1426184190},{\"time\":1426184190}]}" }
25
+
26
+ describe '.get' do
27
+ it 'should call raw_request and build_response_object' do
28
+ allow(@klass).to receive(:raw_request) { json }
29
+ expect(@klass).to receive(:raw_request).with(:get, @klass.path, {})
30
+ expect(@klass).to receive(:build_response_object).with(json)
31
+ @klass.get(@klass.path, {})
32
+ end
33
+ end
34
+
35
+ describe '.delete' do
36
+ it 'should call raw_request' do
37
+ response = double
38
+ allow(response).to receive(:body) { '' }
39
+ allow(@klass).to receive(:raw_request) { response }
40
+ expect(@klass).to receive(:raw_request).with(:delete, @klass.path)
41
+ @klass.delete(@klass.path)
42
+ end
43
+ end
44
+
45
+ describe '.post' do
46
+ it 'should call raw_request and build_response_object' do
47
+ allow(@klass).to receive(:raw_request) { json }
48
+ expect(@klass).to receive(:raw_request).with(:post, @klass.path, {})
49
+ expect(@klass).to receive(:build_response_object).with(json)
50
+ @klass.post(@klass.path, {})
51
+ end
52
+ end
53
+
54
+ describe '.put' do
55
+ it 'should call raw_request and build_response_object' do
56
+ allow(@klass).to receive(:raw_request) { json }
57
+ expect(@klass).to receive(:raw_request).with(:put, @klass.path, {})
58
+ expect(@klass).to receive(:build_response_object).with(json)
59
+ @klass.put(@klass.path, {})
60
+ end
61
+ end
62
+
63
+ describe '.raw_request' do
64
+ before do
65
+ Bigcommerce.configure do |config|
66
+ config.client_id = 'sdbgksjbg4'
67
+ config.access_token = 'jkdgbdsgbg'
68
+ config.store_hash = 'sdgjnsdjg'
69
+ end
70
+ @api = Bigcommerce.api
71
+ end
72
+
73
+ it 'send its method to Bigcommerce.api' do
74
+ response = double
75
+ allow(@api).to receive(:get) { response }
76
+ allow(response).to receive(:headers) { '' }
77
+ expect(@api).to receive(:get).with('path/1', nil)
78
+ expect(response).to receive(:headers)
79
+ @klass.raw_request(:get, 'path/1')
80
+ end
81
+ end
82
+
83
+ describe 'private methods' do
84
+ describe '.build_response_object' do
85
+ before do
86
+ module Bigcommerce
87
+ class DummyClass
88
+ include Request.new 'foo/%d'
89
+ def initialize(params)
90
+ @params = params
91
+ end
92
+ end
93
+ end
94
+ @klass_with_init = Bigcommerce::DummyClass
95
+ end
96
+
97
+ describe 'json array' do
98
+ let(:json) { "[{\"time\":1426184190},{\"time\":1426184190}]" }
99
+
100
+ it 'should build an array of objects' do
101
+ response = double
102
+ allow(response).to receive(:body) { json }
103
+ objs = @klass_with_init.send(:build_response_object, response)
104
+ expect(objs).to be_kind_of Array
105
+ objs.each do |obj|
106
+ expect(obj).to be_kind_of Bigcommerce::DummyClass
107
+ end
108
+ end
109
+ end
110
+ describe 'json object' do
111
+ let(:json) { "{\"time\":1426184190}" }
112
+ it 'should build an object' do
113
+ response = double
114
+ allow(response).to receive(:body) { json }
115
+ objs = @klass_with_init.send(:build_response_object, response)
116
+ expect(objs).to be_kind_of Bigcommerce::DummyClass
117
+ end
118
+ end
119
+ end
120
+
121
+ describe '.parse' do
122
+ describe 'empty string' do
123
+ let(:json) { "" }
124
+
125
+ it 'should return an array' do
126
+ expect(@klass.send(:parse, json)).to be_kind_of Array
127
+ end
128
+ end
129
+
130
+ describe 'valid json' do
131
+ let(:json) { "{\"time\":1426184190}" }
132
+
133
+ it 'should symbolize keys' do
134
+ expect(@klass.send(:parse, json)).to eq({time:1426184190})
135
+ end
136
+
137
+ it 'should return a hash' do
138
+ expect(@klass.send(:parse, json)).to be_kind_of Hash
139
+ end
140
+ end
141
+ end
142
+ end
143
+ end
144
+ end
145
+
146
+ describe Bigcommerce::PathBuilder do
147
+ let(:uri) { 'bar/%d' }
148
+ before do
149
+ @path_builder = Bigcommerce::PathBuilder.new uri
150
+ end
151
+
152
+ describe '.to_s' do
153
+ it 'should return uri' do
154
+ expect(@path_builder.to_s).to eq uri
155
+ end
156
+ end
157
+
158
+ describe '.build' do
159
+ context 'hash of keys' do
160
+ let(:keys) { 1 }
161
+ it 'should build a formed path' do
162
+ expect(@path_builder.build keys).to eq 'bar/1'
163
+ end
164
+ end
165
+
166
+ context 'integer keys' do
167
+ let(:keys) { 1 }
168
+ it 'should build a formed path' do
169
+ expect(@path_builder.build keys).to eq 'bar/1'
170
+ end
171
+ end
172
+
173
+ context 'integer keys' do
174
+ let(:keys) { nil }
175
+ it 'should build a formed path' do
176
+ expect(@path_builder.build keys).to eq 'bar'
177
+ end
178
+ end
179
+ end
180
+ end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ describe Bigcommerce::BlogPost do
4
+ before(:each) { @blog_post = Bigcommerce::BlogPost }
5
+
6
+ describe '.count' do
7
+ it 'should hit the correct path' do
8
+ expect(@blog_post).to receive(:get).with('blog/posts/count')
9
+ @blog_post.count
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ describe Bigcommerce::BlogTag do
4
+ before(:each) { @blog_tag = Bigcommerce::BlogTag }
5
+
6
+ describe '.all' do
7
+ it 'should hit the correct path' do
8
+ expect(@blog_tag).to receive(:get).with(@blog_tag.path.build)
9
+ @blog_tag.all
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ describe Bigcommerce::Redirect do
4
+ before(:each) { @redirect = Bigcommerce::Redirect }
5
+
6
+ describe '.count' do
7
+ it 'should hit the correct path' do
8
+ expect(@redirect).to receive(:get).with('redirects/count')
9
+ @redirect.count
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ describe Bigcommerce::CustomerAddress do
4
+ before(:each) { @address = Bigcommerce::CustomerAddress }
5
+
6
+ let(:params) { 1 }
7
+
8
+ describe '.count' do
9
+ it 'should hit the correct path' do
10
+ expect(@address).to receive(:get).with('customers/1/addresses/count')
11
+ @address.count params
12
+ end
13
+ end
14
+
15
+ describe '.count_all' do
16
+ it 'should hit the correct path' do
17
+ expect(@address).to receive(:get).with('customers/addresses/count')
18
+ @address.count_all
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ describe Bigcommerce::CustomerGroup do
4
+ before(:each) { @group = Bigcommerce::CustomerGroup }
5
+
6
+ describe '.count' do
7
+ it 'should hit the correct path' do
8
+ expect(@group).to receive(:get).with('customer_groups/count')
9
+ @group.count
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ describe Bigcommerce::Customer do
4
+ before(:each) { @customer = Bigcommerce::Customer }
5
+
6
+ describe '.count' do
7
+ it 'should hit the correct path' do
8
+ expect(@customer).to receive(:get).with('customers/count')
9
+ @customer.count
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ describe Bigcommerce::Country do
4
+ before(:each) { @country = Bigcommerce::Country }
5
+
6
+ describe '.count' do
7
+ it 'should hit the correct path' do
8
+ expect(@country).to receive(:get).with('countries/count')
9
+ @country.count
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ describe Bigcommerce::State do
4
+ before(:each) { @state = Bigcommerce::State }
5
+
6
+ let(:params) { 226 }
7
+
8
+ describe '.count' do
9
+ it 'should hit the correct path' do
10
+ expect(@state).to receive(:get).with('countries/226/states/count')
11
+ @state.count params
12
+ end
13
+ end
14
+
15
+ describe '.count_all' do
16
+ it 'should hit the correct path' do
17
+ expect(@state).to receive(:get).with('countries/states/count')
18
+ @state.count_all
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ describe Bigcommerce::Coupon do
4
+ before(:each) { @coupon = Bigcommerce::Coupon }
5
+
6
+ describe '.count' do
7
+ it 'should hit the correct path' do
8
+ expect(@coupon).to receive(:get).with('coupons/count')
9
+ @coupon.count
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ describe Bigcommerce::OrderProduct do
4
+ before(:each) { @order_product = Bigcommerce::OrderProduct }
5
+
6
+ let(:params) { 1 }
7
+
8
+ describe '.count' do
9
+ it 'should hit the correct path' do
10
+ expect(@order_product).to receive(:get).with('orders/1/products/count')
11
+ @order_product.count params
12
+ end
13
+ end
14
+
15
+ describe '.count_all' do
16
+ it 'should hit the correct path' do
17
+ expect(@order_product).to receive(:get).with('orders/products/count')
18
+ @order_product.count_all
19
+ end
20
+ end
21
+ end