patch_ruby 1.2.4 → 1.2.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +9 -0
  3. data/Gemfile +1 -0
  4. data/Gemfile.lock +18 -2
  5. data/lib/patch_ruby/models/allocation.rb +10 -0
  6. data/lib/patch_ruby/models/create_mass_estimate_request.rb +7 -0
  7. data/lib/patch_ruby/models/create_order_request.rb +7 -0
  8. data/lib/patch_ruby/models/create_preference_request.rb +7 -0
  9. data/lib/patch_ruby/models/error_response.rb +9 -0
  10. data/lib/patch_ruby/models/estimate.rb +14 -1
  11. data/lib/patch_ruby/models/estimate_list_response.rb +9 -0
  12. data/lib/patch_ruby/models/estimate_response.rb +9 -0
  13. data/lib/patch_ruby/models/meta_index_object.rb +11 -0
  14. data/lib/patch_ruby/models/order.rb +20 -0
  15. data/lib/patch_ruby/models/order_list_response.rb +9 -0
  16. data/lib/patch_ruby/models/order_response.rb +9 -0
  17. data/lib/patch_ruby/models/photo.rb +21 -4
  18. data/lib/patch_ruby/models/preference.rb +10 -0
  19. data/lib/patch_ruby/models/preference_list_response.rb +9 -0
  20. data/lib/patch_ruby/models/preference_response.rb +9 -0
  21. data/lib/patch_ruby/models/project.rb +22 -0
  22. data/lib/patch_ruby/models/project_list_response.rb +9 -0
  23. data/lib/patch_ruby/models/project_response.rb +9 -0
  24. data/lib/patch_ruby/models/standard.rb +10 -0
  25. data/lib/patch_ruby/version.rb +1 -1
  26. data/spec/factories/allocations.rb +7 -0
  27. data/spec/factories/create_mass_estimate_requests.rb +6 -0
  28. data/spec/factories/create_order_requests.rb +8 -0
  29. data/spec/factories/create_preference_requests.rb +5 -0
  30. data/spec/factories/error_responses.rb +7 -0
  31. data/spec/factories/estimate_list_responses.rb +8 -0
  32. data/spec/factories/estimate_responses.rb +7 -0
  33. data/spec/factories/estimates.rb +8 -0
  34. data/spec/factories/meta_index_objects.rb +6 -0
  35. data/spec/factories/order_list_responses.rb +8 -0
  36. data/spec/factories/order_responses.rb +7 -0
  37. data/spec/factories/orders.rb +12 -0
  38. data/spec/factories/preference_list_responses.rb +8 -0
  39. data/spec/factories/preference_responses.rb +7 -0
  40. data/spec/factories/preferences.rb +7 -0
  41. data/spec/factories/project_list_responses.rb +8 -0
  42. data/spec/factories/project_responses.rb +7 -0
  43. data/spec/factories/projects.rb +15 -0
  44. data/spec/integration/estimates_spec.rb +0 -11
  45. data/spec/integration/orders_spec.rb +1 -1
  46. data/spec/models/allocation_spec.rb +8 -1
  47. data/spec/models/create_mass_estimate_request_spec.rb +7 -1
  48. data/spec/models/create_order_request_spec.rb +7 -1
  49. data/spec/models/create_preference_request_spec.rb +8 -1
  50. data/spec/models/error_response_spec.rb +7 -1
  51. data/spec/models/estimate_list_response_spec.rb +7 -1
  52. data/spec/models/estimate_response_spec.rb +7 -1
  53. data/spec/models/estimate_spec.rb +8 -1
  54. data/spec/models/meta_index_object_spec.rb +7 -1
  55. data/spec/models/order_list_response_spec.rb +7 -1
  56. data/spec/models/order_response_spec.rb +7 -1
  57. data/spec/models/order_spec.rb +18 -1
  58. data/spec/models/preference_list_response_spec.rb +7 -1
  59. data/spec/models/preference_response_spec.rb +7 -1
  60. data/spec/models/preference_spec.rb +7 -1
  61. data/spec/models/project_list_response_spec.rb +7 -1
  62. data/spec/models/project_response_spec.rb +7 -1
  63. data/spec/models/project_spec.rb +21 -1
  64. data/spec/spec_helper.rb +10 -0
  65. data/spec/support/shared/generated_classes.rb +13 -0
  66. metadata +57 -19
@@ -20,13 +20,19 @@ require 'date'
20
20
  describe 'ErrorResponse' do
21
21
  before do
22
22
  # run before each test
23
- @instance = Patch::ErrorResponse.new
23
+ @instance = build(:error_response)
24
24
  end
25
25
 
26
26
  after do
27
27
  # run after each test
28
28
  end
29
29
 
30
+ it_behaves_like "a generated class" do
31
+ let(:instance) { @instance }
32
+ let(:instance_hash) { { success: @instance.success, error: @instance.error, data: @instance.data } }
33
+ let(:nullable_properties) { Set.new(["data"]) }
34
+ end
35
+
30
36
  describe 'test an instance of ErrorResponse' do
31
37
  it 'should create an instance of ErrorResponse' do
32
38
  expect(@instance).to be_instance_of(Patch::ErrorResponse)
@@ -20,13 +20,19 @@ require 'date'
20
20
  describe 'EstimateListResponse' do
21
21
  before do
22
22
  # run before each test
23
- @instance = Patch::EstimateListResponse.new
23
+ @instance = build(:estimate_list_response)
24
24
  end
25
25
 
26
26
  after do
27
27
  # run after each test
28
28
  end
29
29
 
30
+ it_behaves_like "a generated class" do
31
+ let(:instance) { @instance }
32
+ let(:instance_hash) { { success: @instance.success, error: @instance.error, data: @instance.data, meta: @instance.meta } }
33
+ let(:nullable_properties) { Set.new(["error"]) }
34
+ end
35
+
30
36
  describe 'test an instance of EstimateListResponse' do
31
37
  it 'should create an instance of EstimateListResponse' do
32
38
  expect(@instance).to be_instance_of(Patch::EstimateListResponse)
@@ -20,13 +20,19 @@ require 'date'
20
20
  describe 'EstimateResponse' do
21
21
  before do
22
22
  # run before each test
23
- @instance = Patch::EstimateResponse.new
23
+ @instance = build(:estimate_response)
24
24
  end
25
25
 
26
26
  after do
27
27
  # run after each test
28
28
  end
29
29
 
30
+ it_behaves_like "a generated class" do
31
+ let(:instance) { @instance }
32
+ let(:instance_hash) { { success: @instance.success, error: @instance.error, data: @instance.data } }
33
+ let(:nullable_properties) { Set.new(["error"]) }
34
+ end
35
+
30
36
  describe 'test an instance of EstimateResponse' do
31
37
  it 'should create an instance of EstimateResponse' do
32
38
  expect(@instance).to be_instance_of(Patch::EstimateResponse)
@@ -20,18 +20,25 @@ require 'date'
20
20
  describe 'Estimate' do
21
21
  before do
22
22
  # run before each test
23
- @instance = Patch::Estimate.new
23
+ @instance = build(:estimate)
24
24
  end
25
25
 
26
26
  after do
27
27
  # run after each test
28
28
  end
29
29
 
30
+ it_behaves_like "a generated class" do
31
+ let(:instance) { @instance }
32
+ let(:instance_hash) { { id: @instance.id, order: @instance.order.to_hash, production: @instance.production, type: @instance.type } }
33
+ let(:nullable_properties) { Set.new(["order"]) }
34
+ end
35
+
30
36
  describe 'test an instance of Estimate' do
31
37
  it 'should create an instance of Estimate' do
32
38
  expect(@instance).to be_instance_of(Patch::Estimate)
33
39
  end
34
40
  end
41
+
35
42
  describe 'test attribute "id"' do
36
43
  it 'should work' do
37
44
  # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
@@ -20,13 +20,19 @@ require 'date'
20
20
  describe 'MetaIndexObject' do
21
21
  before do
22
22
  # run before each test
23
- @instance = Patch::MetaIndexObject.new
23
+ @instance = build(:meta_index_object)
24
24
  end
25
25
 
26
26
  after do
27
27
  # run after each test
28
28
  end
29
29
 
30
+ it_behaves_like "a generated class" do
31
+ let(:instance) { @instance }
32
+ let(:instance_hash) { { next_page: @instance.next_page, prev_page: @instance.prev_page } }
33
+ let(:nullable_properties) { Set.new(["next_page", "prev_page"]) }
34
+ end
35
+
30
36
  describe 'test an instance of MetaIndexObject' do
31
37
  it 'should create an instance of MetaIndexObject' do
32
38
  expect(@instance).to be_instance_of(Patch::MetaIndexObject)
@@ -20,13 +20,19 @@ require 'date'
20
20
  describe 'OrderListResponse' do
21
21
  before do
22
22
  # run before each test
23
- @instance = Patch::OrderListResponse.new
23
+ @instance = build(:order_list_response)
24
24
  end
25
25
 
26
26
  after do
27
27
  # run after each test
28
28
  end
29
29
 
30
+ it_behaves_like "a generated class" do
31
+ let(:instance) { @instance }
32
+ let(:instance_hash) { { success: @instance.success, error: @instance.error, data: @instance.data, meta: @instance.meta } }
33
+ let(:nullable_properties) { Set.new(["error"]) }
34
+ end
35
+
30
36
  describe 'test an instance of OrderListResponse' do
31
37
  it 'should create an instance of OrderListResponse' do
32
38
  expect(@instance).to be_instance_of(Patch::OrderListResponse)
@@ -20,13 +20,19 @@ require 'date'
20
20
  describe 'OrderResponse' do
21
21
  before do
22
22
  # run before each test
23
- @instance = Patch::OrderResponse.new
23
+ @instance = build(:order_response)
24
24
  end
25
25
 
26
26
  after do
27
27
  # run after each test
28
28
  end
29
29
 
30
+ it_behaves_like "a generated class" do
31
+ let(:instance) { @instance }
32
+ let(:instance_hash) { { success: @instance.success, error: @instance.error, data: @instance.data } }
33
+ let(:nullable_properties) { Set.new(["error"]) }
34
+ end
35
+
30
36
  describe 'test an instance of OrderResponse' do
31
37
  it 'should create an instance of OrderResponse' do
32
38
  expect(@instance).to be_instance_of(Patch::OrderResponse)
@@ -20,13 +20,30 @@ require 'date'
20
20
  describe 'Order' do
21
21
  before do
22
22
  # run before each test
23
- @instance = Patch::Order.new
23
+ @instance = build(:order)
24
24
  end
25
25
 
26
26
  after do
27
27
  # run after each test
28
28
  end
29
29
 
30
+ it_behaves_like "a generated class" do
31
+ let(:instance) { @instance }
32
+ let(:instance_hash) {
33
+ {
34
+ id: @instance.id,
35
+ mass_g: @instance.mass_g,
36
+ production: @instance.production,
37
+ state: @instance.state,
38
+ allocation_state: @instance.allocation_state,
39
+ price_cents_usd: @instance.price_cents_usd,
40
+ patch_fee_cents_usd: @instance.patch_fee_cents_usd,
41
+ metadata: @instance.metadata
42
+ }
43
+ }
44
+ let(:nullable_properties) { Set.new(["patch_fee_cents_usd", "price_cents_usd"]) }
45
+ end
46
+
30
47
  describe 'test an instance of Order' do
31
48
  it 'should create an instance of Order' do
32
49
  expect(@instance).to be_instance_of(Patch::Order)
@@ -20,13 +20,19 @@ require 'date'
20
20
  describe 'PreferenceListResponse' do
21
21
  before do
22
22
  # run before each test
23
- @instance = Patch::PreferenceListResponse.new
23
+ @instance = build(:preference_list_response)
24
24
  end
25
25
 
26
26
  after do
27
27
  # run after each test
28
28
  end
29
29
 
30
+ it_behaves_like "a generated class" do
31
+ let(:instance) { @instance }
32
+ let(:instance_hash) { { success: @instance.success, error: @instance.error, data: @instance.data, meta: @instance.meta } }
33
+ let(:nullable_properties) { Set.new(["error"]) }
34
+ end
35
+
30
36
  describe 'test an instance of PreferenceListResponse' do
31
37
  it 'should create an instance of PreferenceListResponse' do
32
38
  expect(@instance).to be_instance_of(Patch::PreferenceListResponse)
@@ -20,13 +20,19 @@ require 'date'
20
20
  describe 'PreferenceResponse' do
21
21
  before do
22
22
  # run before each test
23
- @instance = Patch::PreferenceResponse.new
23
+ @instance = build(:preference_response)
24
24
  end
25
25
 
26
26
  after do
27
27
  # run after each test
28
28
  end
29
29
 
30
+ it_behaves_like "a generated class" do
31
+ let(:instance) { @instance }
32
+ let(:instance_hash) { { success: @instance.success, error: @instance.error, data: @instance.data } }
33
+ let(:nullable_properties) { Set.new(["error"]) }
34
+ end
35
+
30
36
  describe 'test an instance of PreferenceResponse' do
31
37
  it 'should create an instance of PreferenceResponse' do
32
38
  expect(@instance).to be_instance_of(Patch::PreferenceResponse)
@@ -20,13 +20,19 @@ require 'date'
20
20
  describe 'Preference' do
21
21
  before do
22
22
  # run before each test
23
- @instance = Patch::Preference.new
23
+ @instance = build(:preference)
24
24
  end
25
25
 
26
26
  after do
27
27
  # run after each test
28
28
  end
29
29
 
30
+ it_behaves_like "a generated class" do
31
+ let(:instance) { @instance }
32
+ let(:instance_hash) { { id: @instance.id, project: @instance.project.to_hash, allocation_percentage: @instance.allocation_percentage } }
33
+ let(:nullable_properties) { Set.new }
34
+ end
35
+
30
36
  describe 'test an instance of Preference' do
31
37
  it 'should create an instance of Preference' do
32
38
  expect(@instance).to be_instance_of(Patch::Preference)
@@ -20,13 +20,19 @@ require 'date'
20
20
  describe 'ProjectListResponse' do
21
21
  before do
22
22
  # run before each test
23
- @instance = Patch::ProjectListResponse.new
23
+ @instance = build(:project_list_response)
24
24
  end
25
25
 
26
26
  after do
27
27
  # run after each test
28
28
  end
29
29
 
30
+ it_behaves_like "a generated class" do
31
+ let(:instance) { @instance }
32
+ let(:instance_hash) { { success: @instance.success, error: @instance.error, data: @instance.data, meta: @instance.meta } }
33
+ let(:nullable_properties) { Set.new(["error"]) }
34
+ end
35
+
30
36
  describe 'test an instance of ProjectListResponse' do
31
37
  it 'should create an instance of ProjectListResponse' do
32
38
  expect(@instance).to be_instance_of(Patch::ProjectListResponse)
@@ -20,13 +20,19 @@ require 'date'
20
20
  describe 'ProjectResponse' do
21
21
  before do
22
22
  # run before each test
23
- @instance = Patch::ProjectResponse.new
23
+ @instance = build(:project_response)
24
24
  end
25
25
 
26
26
  after do
27
27
  # run after each test
28
28
  end
29
29
 
30
+ it_behaves_like "a generated class" do
31
+ let(:instance) { @instance }
32
+ let(:instance_hash) { { success: @instance.success, error: @instance.error, data: @instance.data } }
33
+ let(:nullable_properties) { Set.new(["error"]) }
34
+ end
35
+
30
36
  describe 'test an instance of ProjectResponse' do
31
37
  it 'should create an instance of ProjectResponse' do
32
38
  expect(@instance).to be_instance_of(Patch::ProjectResponse)
@@ -20,13 +20,33 @@ require 'date'
20
20
  describe 'Project' do
21
21
  before do
22
22
  # run before each test
23
- @instance = Patch::Project.new
23
+ @instance = build(:project)
24
24
  end
25
25
 
26
26
  after do
27
27
  # run after each test
28
28
  end
29
29
 
30
+ it_behaves_like "a generated class" do
31
+ let(:instance) { @instance }
32
+ let(:instance_hash) {
33
+ {
34
+ id: @instance.id,
35
+ name: @instance.name,
36
+ description: @instance.description,
37
+ production: @instance.production,
38
+ type: @instance.type,
39
+ country: @instance.country,
40
+ developer: @instance.developer,
41
+ photos: @instance.photos,
42
+ average_price_per_tonne_cents_usd: @instance.average_price_per_tonne_cents_usd,
43
+ remaining_mass_g: @instance.remaining_mass_g,
44
+ standard: @instance.standard
45
+ }
46
+ }
47
+ let(:nullable_properties) { Set.new(["photos", "standard"]) }
48
+ end
49
+
30
50
  describe 'test an instance of Project' do
31
51
  it 'should create an instance of Project' do
32
52
  expect(@instance).to be_instance_of(Patch::Project)
@@ -13,6 +13,10 @@ OpenAPI Generator version: 4.3.1
13
13
  # load the gem
14
14
  require 'patch_ruby'
15
15
  require 'constants'
16
+ require 'factory_bot'
17
+
18
+ # Require shared spec examples
19
+ Dir["./spec/support/**/*.rb"].sort.each { |f| require f }
16
20
 
17
21
  # The following was generated by the `rspec --init` command. Conventionally, all
18
22
  # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
@@ -33,6 +37,12 @@ require 'constants'
33
37
  #
34
38
  # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
35
39
  RSpec.configure do |config|
40
+ # Use FactoryBot for test factories
41
+ config.include FactoryBot::Syntax::Methods
42
+ config.before(:suite) do
43
+ FactoryBot.find_definitions
44
+ end
45
+
36
46
  # rspec-expectations config goes here. You can use an alternate
37
47
  # assertion/expectation library such as wrong or the stdlib/minitest
38
48
  # assertions if you prefer.
@@ -0,0 +1,13 @@
1
+ RSpec.shared_examples "a generated class" do
2
+ describe '.openapi_nullable' do
3
+ it 'returns a set with nullable properties' do
4
+ expect(instance.class.openapi_nullable).to eq nullable_properties
5
+ end
6
+ end
7
+
8
+ describe '#to_hash' do
9
+ it 'returns a set with nullable properties' do
10
+ expect(@instance.to_hash).to eq(instance_hash)
11
+ end
12
+ end
13
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: patch_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.4
4
+ version: 1.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patch Technology
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-14 00:00:00.000000000 Z
11
+ date: 2021-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: typhoeus
@@ -120,6 +120,24 @@ files:
120
120
  - spec/api_client_spec.rb
121
121
  - spec/configuration_spec.rb
122
122
  - spec/constants.rb
123
+ - spec/factories/allocations.rb
124
+ - spec/factories/create_mass_estimate_requests.rb
125
+ - spec/factories/create_order_requests.rb
126
+ - spec/factories/create_preference_requests.rb
127
+ - spec/factories/error_responses.rb
128
+ - spec/factories/estimate_list_responses.rb
129
+ - spec/factories/estimate_responses.rb
130
+ - spec/factories/estimates.rb
131
+ - spec/factories/meta_index_objects.rb
132
+ - spec/factories/order_list_responses.rb
133
+ - spec/factories/order_responses.rb
134
+ - spec/factories/orders.rb
135
+ - spec/factories/preference_list_responses.rb
136
+ - spec/factories/preference_responses.rb
137
+ - spec/factories/preferences.rb
138
+ - spec/factories/project_list_responses.rb
139
+ - spec/factories/project_responses.rb
140
+ - spec/factories/projects.rb
123
141
  - spec/integration/estimates_spec.rb
124
142
  - spec/integration/orders_spec.rb
125
143
  - spec/integration/preferences_spec.rb
@@ -143,6 +161,7 @@ files:
143
161
  - spec/models/project_response_spec.rb
144
162
  - spec/models/project_spec.rb
145
163
  - spec/spec_helper.rb
164
+ - spec/support/shared/generated_classes.rb
146
165
  homepage: https://www.usepatch.com
147
166
  licenses:
148
167
  - MIT
@@ -167,33 +186,52 @@ signing_key:
167
186
  specification_version: 4
168
187
  summary: Ruby wrapper for the Patch API
169
188
  test_files:
189
+ - spec/api/projects_api_spec.rb
190
+ - spec/api/orders_api_spec.rb
170
191
  - spec/api/preferences_api_spec.rb
171
192
  - spec/api/estimates_api_spec.rb
172
- - spec/api/orders_api_spec.rb
173
- - spec/api/projects_api_spec.rb
174
193
  - spec/api_client_spec.rb
175
194
  - spec/configuration_spec.rb
176
195
  - spec/constants.rb
177
- - spec/integration/projects_spec.rb
178
- - spec/integration/preferences_spec.rb
179
- - spec/integration/estimates_spec.rb
196
+ - spec/factories/estimates.rb
197
+ - spec/factories/estimate_list_responses.rb
198
+ - spec/factories/create_order_requests.rb
199
+ - spec/factories/project_list_responses.rb
200
+ - spec/factories/order_list_responses.rb
201
+ - spec/factories/estimate_responses.rb
202
+ - spec/factories/error_responses.rb
203
+ - spec/factories/preference_list_responses.rb
204
+ - spec/factories/preference_responses.rb
205
+ - spec/factories/meta_index_objects.rb
206
+ - spec/factories/order_responses.rb
207
+ - spec/factories/preferences.rb
208
+ - spec/factories/project_responses.rb
209
+ - spec/factories/create_preference_requests.rb
210
+ - spec/factories/orders.rb
211
+ - spec/factories/projects.rb
212
+ - spec/factories/create_mass_estimate_requests.rb
213
+ - spec/factories/allocations.rb
180
214
  - spec/integration/orders_spec.rb
181
- - spec/models/order_response_spec.rb
182
- - spec/models/estimate_list_response_spec.rb
183
- - spec/models/project_spec.rb
184
- - spec/models/estimate_response_spec.rb
185
- - spec/models/project_response_spec.rb
215
+ - spec/integration/estimates_spec.rb
216
+ - spec/integration/preferences_spec.rb
217
+ - spec/integration/projects_spec.rb
186
218
  - spec/models/error_response_spec.rb
187
- - spec/models/estimate_spec.rb
188
- - spec/models/create_mass_estimate_request_spec.rb
189
- - spec/models/project_list_response_spec.rb
219
+ - spec/models/preference_list_response_spec.rb
190
220
  - spec/models/preference_spec.rb
191
- - spec/models/create_order_request_spec.rb
221
+ - spec/models/project_response_spec.rb
222
+ - spec/models/project_spec.rb
223
+ - spec/models/create_preference_request_spec.rb
224
+ - spec/models/order_response_spec.rb
192
225
  - spec/models/order_list_response_spec.rb
193
- - spec/models/preference_list_response_spec.rb
194
- - spec/models/preference_response_spec.rb
195
226
  - spec/models/allocation_spec.rb
227
+ - spec/models/estimate_response_spec.rb
196
228
  - spec/models/order_spec.rb
197
229
  - spec/models/meta_index_object_spec.rb
198
- - spec/models/create_preference_request_spec.rb
230
+ - spec/models/project_list_response_spec.rb
231
+ - spec/models/preference_response_spec.rb
232
+ - spec/models/estimate_spec.rb
233
+ - spec/models/create_mass_estimate_request_spec.rb
234
+ - spec/models/estimate_list_response_spec.rb
235
+ - spec/models/create_order_request_spec.rb
199
236
  - spec/spec_helper.rb
237
+ - spec/support/shared/generated_classes.rb