Skip to content

Commit 231b723

Browse files
committed
Add factories; refactor specs to services
1 parent e11605b commit 231b723

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+335
-126
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414
- Fixes [issues/5](https://github.com/patch-technology/patch-ruby/issues/5). Adds method `.openapi_nullable` which returns a set with all nullable properties. This method is referenced in `#to_hash` which returns a hash representation of the resource.
1515
- Removes non-deterministic integration spec that is creating an Estimate with a specific project-id. Since we do not control the test data (yet) and make queries against our Test projects, we cannot be sure that we will have offsets available for a project ID. Instead we can rely on Patch core specs to cover this.
1616
- Fixes a spec that was failing due to a Patch core change.
17+
- Add spec factories and refactor generated method specs to shared examples.
1718

1819
## [1.2.4] - 2020-10-14
1920

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ group :development, :test do
66
gem 'rake', '~> 13.0.1'
77
gem 'pry-byebug'
88
gem 'rubocop'
9+
gem 'factory_bot'
910
end

Gemfile.lock

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,27 @@ PATH
88
GEM
99
remote: https://rubygems.org/
1010
specs:
11+
activesupport (6.1.1)
12+
concurrent-ruby (~> 1.0, >= 1.0.2)
13+
i18n (>= 1.6, < 2)
14+
minitest (>= 5.1)
15+
tzinfo (~> 2.0)
16+
zeitwerk (~> 2.3)
1117
ast (2.4.1)
1218
byebug (11.1.3)
1319
coderay (1.1.3)
20+
concurrent-ruby (1.1.7)
1421
diff-lcs (1.4.3)
1522
ethon (0.12.0)
1623
ffi (>= 1.3.0)
24+
factory_bot (6.1.0)
25+
activesupport (>= 5.0.0)
1726
ffi (1.13.1)
27+
i18n (1.8.7)
28+
concurrent-ruby (~> 1.0)
1829
json (2.4.1)
1930
method_source (1.0.0)
31+
minitest (5.14.3)
2032
parallel (1.19.2)
2133
parser (2.7.1.4)
2234
ast (~> 2.4.1)
@@ -57,12 +69,16 @@ GEM
5769
ruby-progressbar (1.10.1)
5870
typhoeus (1.4.0)
5971
ethon (>= 0.9.0)
72+
tzinfo (2.0.4)
73+
concurrent-ruby (~> 1.0)
6074
unicode-display_width (1.7.0)
75+
zeitwerk (2.4.2)
6176

6277
PLATFORMS
6378
ruby
6479

6580
DEPENDENCIES
81+
factory_bot
6682
patch_ruby!
6783
pry-byebug
6884
rake (~> 13.0.1)

spec/factories/allocations.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FactoryBot.define do
2+
factory :allocation, class: Patch::Allocation do
3+
sequence(:id) { |n| n }
4+
production { false }
5+
mass_g { 100 }
6+
end
7+
end
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FactoryBot.define do
2+
factory :create_mass_estimate_request, class: Patch::CreateMassEstimateRequest do
3+
sequence(:project_id) { |n| n }
4+
mass_g { 100 }
5+
end
6+
end
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FactoryBot.define do
2+
factory :create_order_request, class: Patch::CreateOrderRequest do
3+
sequence(:project_id) { |n| n }
4+
mass_g { 100 }
5+
total_price_cents_usd { 100 }
6+
metadata { {} }
7+
end
8+
end
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FactoryBot.define do
2+
factory :create_preference_request, class: Patch::CreatePreferenceRequest do
3+
sequence(:project_id) { |n| n }
4+
end
5+
end

spec/factories/error_responses.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FactoryBot.define do
2+
factory :error_response, class: Patch::ErrorResponse do
3+
success { true }
4+
error { {} }
5+
data { {} }
6+
end
7+
end
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FactoryBot.define do
2+
factory :estimate_list_response, class: Patch::EstimateListResponse do
3+
success { true }
4+
error { {} }
5+
data { {} }
6+
meta { {} }
7+
end
8+
end

spec/factories/estimate_responses.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FactoryBot.define do
2+
factory :estimate_response, class: Patch::EstimateResponse do
3+
success { true }
4+
error { {} }
5+
data { {} }
6+
end
7+
end

0 commit comments

Comments
 (0)