cucumber_factory 2.4.1 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/Gemfile.cucumber-1.3.lock +1 -1
- data/Gemfile.cucumber-2.4.lock +1 -1
- data/Gemfile.cucumber-3.0.lock +1 -1
- data/Gemfile.cucumber-3.1.lock +1 -1
- data/Gemfile.cucumber-4.1.lock +1 -1
- data/Gemfile.cucumber-5.3.lock +1 -1
- data/Gemfile.rails-7.lock +1 -1
- data/lib/cucumber_factory/build_strategy.rb +10 -2
- data/lib/cucumber_factory/factory.rb +3 -0
- data/lib/cucumber_factory/version.rb +1 -1
- data/spec/cucumber_factory/factory/build_strategy_spec.rb +6 -0
- data/spec/cucumber_factory/steps_spec.rb +8 -0
- data/spec/support/factories/factories.rb +4 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bf3824a0f6c872595184e9e5b772fd86a1620d680ad201cde8b07fb53d57541c
|
4
|
+
data.tar.gz: cfc9cf7ffa2f07b79f307f058525a4c14db4d27f40cd57b7c17768994d4e71fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bbf5e11cd62c8fe595c782ba1d216ce430363eb6bd38dc8a2ce918851afd30bf01af8c6dfa95ded9a9612b9264e2479a466e3539358557340e7cede1eabc815a
|
7
|
+
data.tar.gz: c92ba2dac384b42969ef024d15afd7a368f72f80e5ec2c1f6d3bbb83dc4135a151ebe70d45c09b018fddfd5e4ae501a7cbcc01dc9d292652d95e1c066e0eb161
|
data/CHANGELOG.md
CHANGED
@@ -15,6 +15,12 @@ This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html
|
|
15
15
|
|
16
16
|
-
|
17
17
|
|
18
|
+
## 2.5.0 - 2022-09-15
|
19
|
+
|
20
|
+
### Compatible changes
|
21
|
+
|
22
|
+
- Treat transient factory_bot attributes as associations if they are named like a factory.
|
23
|
+
|
18
24
|
## 2.4.1 - 2022-03-16
|
19
25
|
|
20
26
|
### Compatible changes
|
data/Gemfile.cucumber-1.3.lock
CHANGED
data/Gemfile.cucumber-2.4.lock
CHANGED
data/Gemfile.cucumber-3.0.lock
CHANGED
data/Gemfile.cucumber-3.1.lock
CHANGED
data/Gemfile.cucumber-4.1.lock
CHANGED
data/Gemfile.cucumber-5.3.lock
CHANGED
data/Gemfile.rails-7.lock
CHANGED
@@ -22,6 +22,12 @@ module CucumberFactory
|
|
22
22
|
[strategy, transient_attributes]
|
23
23
|
end
|
24
24
|
|
25
|
+
def class_from_factory(model_prose)
|
26
|
+
if (factory = factory_bot_factory(model_prose, []))
|
27
|
+
factory.build_class
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
25
31
|
def parse_model_class(model_prose)
|
26
32
|
underscored_model_name(model_prose).camelize.constantize
|
27
33
|
end
|
@@ -40,11 +46,13 @@ module CucumberFactory
|
|
40
46
|
def factory_bot_factory(model_prose, variants)
|
41
47
|
return unless factory_bot_class
|
42
48
|
|
49
|
+
factories = factory_bot_class.factories
|
50
|
+
|
43
51
|
factory_name = factory_name_from_prose(model_prose)
|
44
|
-
factory =
|
52
|
+
factory = factories.registered?(factory_name) && factories[factory_name]
|
45
53
|
|
46
54
|
if factory.nil? && variants.present?
|
47
|
-
factory =
|
55
|
+
factory = factories.registered?(variants[0]) && factories[variants[0]]
|
48
56
|
end
|
49
57
|
|
50
58
|
factory
|
@@ -207,6 +207,9 @@ module CucumberFactory
|
|
207
207
|
if Object.const_defined?(klass_name)
|
208
208
|
association_class = klass_name.constantize
|
209
209
|
associated = true
|
210
|
+
elsif (factory_class = CucumberFactory::BuildStrategy.class_from_factory(attribute.to_s))
|
211
|
+
association_class = factory_class
|
212
|
+
associated = true
|
210
213
|
end
|
211
214
|
else
|
212
215
|
associated = false
|
@@ -304,6 +304,14 @@ describe 'steps provided by cucumber_factory' do
|
|
304
304
|
user.reviewed_movies.first.title.should == 'Sunshine'
|
305
305
|
end
|
306
306
|
|
307
|
+
it 'allow associations for transient attributes if they are named like a factory' do
|
308
|
+
invoke_cucumber_step('there is a movie with the title "Sunshine"')
|
309
|
+
invoke_cucumber_step('there is a user with the film "Sunshine"')
|
310
|
+
user = User.last
|
311
|
+
user.reviewed_movies.count.should == 1
|
312
|
+
user.reviewed_movies.first.title.should == 'Sunshine'
|
313
|
+
end
|
314
|
+
|
307
315
|
it "should allow to set attributes via doc string" do
|
308
316
|
user = User.new
|
309
317
|
User.stub(:new => user)
|
@@ -16,11 +16,12 @@ FactoryBot.define do
|
|
16
16
|
factory :user, :class => User do
|
17
17
|
transient do
|
18
18
|
movie { nil }
|
19
|
+
film { nil }
|
19
20
|
end
|
20
21
|
|
21
22
|
after(:build) do |user, evaluator|
|
22
|
-
if user.reviewed_movies.blank? && evaluator.movie
|
23
|
-
user.reviewed_movies << evaluator.movie
|
23
|
+
if user.reviewed_movies.blank? && (evaluator.movie || evaluator.film)
|
24
|
+
user.reviewed_movies << (evaluator.movie || evaluator.film)
|
24
25
|
end
|
25
26
|
end
|
26
27
|
end
|
@@ -43,4 +44,5 @@ FactoryBot.define do
|
|
43
44
|
factory :opera, :class => Opera
|
44
45
|
factory :payment, :class => Payment
|
45
46
|
factory :uuid_user, :class => UuidUser
|
47
|
+
factory :film, :class => Movie
|
46
48
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cucumber_factory
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Henning Koch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-09-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cucumber
|
@@ -146,7 +146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
146
146
|
- !ruby/object:Gem::Version
|
147
147
|
version: '0'
|
148
148
|
requirements: []
|
149
|
-
rubygems_version: 3.3.
|
149
|
+
rubygems_version: 3.3.22
|
150
150
|
signing_key:
|
151
151
|
specification_version: 4
|
152
152
|
summary: Create records from Cucumber features without writing step definitions.
|