patch_ruby 1.2.2 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +42 -2
  3. data/Gemfile +1 -0
  4. data/Gemfile.lock +19 -3
  5. data/Makefile +10 -0
  6. data/README.md +61 -4
  7. data/lib/patch_ruby/api/estimates_api.rb +195 -0
  8. data/lib/patch_ruby/api/projects_api.rb +9 -0
  9. data/lib/patch_ruby/models/allocation.rb +10 -0
  10. data/lib/patch_ruby/models/create_mass_estimate_request.rb +19 -1
  11. data/lib/patch_ruby/models/create_order_request.rb +38 -16
  12. data/lib/patch_ruby/models/create_preference_request.rb +7 -0
  13. data/lib/patch_ruby/models/error_response.rb +9 -0
  14. data/lib/patch_ruby/models/estimate.rb +24 -1
  15. data/lib/patch_ruby/models/estimate_list_response.rb +9 -0
  16. data/lib/patch_ruby/models/estimate_response.rb +9 -0
  17. data/lib/patch_ruby/models/meta_index_object.rb +11 -0
  18. data/lib/patch_ruby/models/order.rb +30 -1
  19. data/lib/patch_ruby/models/order_list_response.rb +9 -0
  20. data/lib/patch_ruby/models/order_response.rb +9 -0
  21. data/lib/patch_ruby/models/photo.rb +30 -4
  22. data/lib/patch_ruby/models/preference.rb +10 -0
  23. data/lib/patch_ruby/models/preference_list_response.rb +9 -0
  24. data/lib/patch_ruby/models/preference_response.rb +9 -0
  25. data/lib/patch_ruby/models/project.rb +40 -4
  26. data/lib/patch_ruby/models/project_list_response.rb +9 -0
  27. data/lib/patch_ruby/models/project_response.rb +9 -0
  28. data/lib/patch_ruby/models/sdg.rb +269 -0
  29. data/lib/patch_ruby/models/standard.rb +10 -0
  30. data/lib/patch_ruby/version.rb +1 -1
  31. data/spec/constants.rb +3 -0
  32. data/spec/factories/allocations.rb +7 -0
  33. data/spec/factories/create_mass_estimate_requests.rb +6 -0
  34. data/spec/factories/create_order_requests.rb +8 -0
  35. data/spec/factories/create_preference_requests.rb +5 -0
  36. data/spec/factories/error_responses.rb +7 -0
  37. data/spec/factories/estimate_list_responses.rb +8 -0
  38. data/spec/factories/estimate_responses.rb +7 -0
  39. data/spec/factories/estimates.rb +8 -0
  40. data/spec/factories/meta_index_objects.rb +6 -0
  41. data/spec/factories/order_list_responses.rb +8 -0
  42. data/spec/factories/order_responses.rb +7 -0
  43. data/spec/factories/orders.rb +12 -0
  44. data/spec/factories/preference_list_responses.rb +8 -0
  45. data/spec/factories/preference_responses.rb +7 -0
  46. data/spec/factories/preferences.rb +7 -0
  47. data/spec/factories/project_list_responses.rb +8 -0
  48. data/spec/factories/project_responses.rb +7 -0
  49. data/spec/factories/projects.rb +15 -0
  50. data/spec/integration/estimates_spec.rb +53 -9
  51. data/spec/integration/orders_spec.rb +42 -5
  52. data/spec/integration/preferences_spec.rb +7 -3
  53. data/spec/integration/projects_spec.rb +21 -1
  54. data/spec/models/allocation_spec.rb +8 -1
  55. data/spec/models/create_mass_estimate_request_spec.rb +7 -1
  56. data/spec/models/create_order_request_spec.rb +7 -1
  57. data/spec/models/create_preference_request_spec.rb +8 -1
  58. data/spec/models/error_response_spec.rb +7 -1
  59. data/spec/models/estimate_list_response_spec.rb +7 -1
  60. data/spec/models/estimate_response_spec.rb +7 -1
  61. data/spec/models/estimate_spec.rb +8 -1
  62. data/spec/models/meta_index_object_spec.rb +7 -1
  63. data/spec/models/order_list_response_spec.rb +7 -1
  64. data/spec/models/order_response_spec.rb +7 -1
  65. data/spec/models/order_spec.rb +18 -1
  66. data/spec/models/preference_list_response_spec.rb +7 -1
  67. data/spec/models/preference_response_spec.rb +7 -1
  68. data/spec/models/preference_spec.rb +7 -1
  69. data/spec/models/project_list_response_spec.rb +7 -1
  70. data/spec/models/project_response_spec.rb +7 -1
  71. data/spec/models/project_spec.rb +21 -1
  72. data/spec/spec_helper.rb +11 -0
  73. data/spec/support/shared/generated_classes.rb +13 -0
  74. metadata +56 -14
@@ -20,13 +20,19 @@ require 'date'
20
20
  describe 'CreateMassEstimateRequest' do
21
21
  before do
22
22
  # run before each test
23
- @instance = Patch::CreateMassEstimateRequest.new
23
+ @instance = build(:create_mass_estimate_request)
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) { { project_id: @instance.project_id, mass_g: @instance.mass_g } }
33
+ let(:nullable_properties) { Set.new(["create_order"]) }
34
+ end
35
+
30
36
  describe 'test an instance of CreateMassEstimateRequest' do
31
37
  it 'should create an instance of CreateMassEstimateRequest' do
32
38
  expect(@instance).to be_instance_of(Patch::CreateMassEstimateRequest)
@@ -20,13 +20,19 @@ require 'date'
20
20
  describe 'CreateOrderRequest' do
21
21
  before do
22
22
  # run before each test
23
- @instance = Patch::CreateOrderRequest.new
23
+ @instance = build(:create_order_request)
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) { { project_id: @instance.project_id, mass_g: @instance.mass_g, total_price_cents_usd: @instance.total_price_cents_usd, metadata: @instance.metadata } }
33
+ let(:nullable_properties) { Set.new }
34
+ end
35
+
30
36
  describe 'test an instance of CreateOrderRequest' do
31
37
  it 'should create an instance of CreateOrderRequest' do
32
38
  expect(@instance).to be_instance_of(Patch::CreateOrderRequest)
@@ -20,18 +20,25 @@ require 'date'
20
20
  describe 'CreatePreferenceRequest' do
21
21
  before do
22
22
  # run before each test
23
- @instance = Patch::CreatePreferenceRequest.new
23
+ @instance = build(:create_preference_request)
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) { { project_id: @instance.project_id } }
33
+ let(:nullable_properties) { Set.new }
34
+ end
35
+
30
36
  describe 'test an instance of CreatePreferenceRequest' do
31
37
  it 'should create an instance of CreatePreferenceRequest' do
32
38
  expect(@instance).to be_instance_of(Patch::CreatePreferenceRequest)
33
39
  end
34
40
  end
41
+
35
42
  describe 'test attribute "project_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 '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", "sdgs"]) }
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)
data/spec/spec_helper.rb CHANGED
@@ -12,6 +12,11 @@ OpenAPI Generator version: 4.3.1
12
12
 
13
13
  # load the gem
14
14
  require 'patch_ruby'
15
+ require 'constants'
16
+ require 'factory_bot'
17
+
18
+ # Require shared spec examples
19
+ Dir["./spec/support/**/*.rb"].sort.each { |f| require f }
15
20
 
16
21
  # The following was generated by the `rspec --init` command. Conventionally, all
17
22
  # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
@@ -32,6 +37,12 @@ require 'patch_ruby'
32
37
  #
33
38
  # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
34
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
+
35
46
  # rspec-expectations config goes here. You can use an alternate
36
47
  # assertion/expectation library such as wrong or the stdlib/minitest
37
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