factory_strategist 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +3 -2
- data/README.md +2 -2
- data/lib/factory_strategist/configure.rb +26 -11
- data/lib/factory_strategist/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a0ce7f02ee00b07efad3acb9b46edec6e555e6a271cb8cf380f4a7da0d447780
|
4
|
+
data.tar.gz: 3fefcdb5cdad957f34c19c5cb4cb36106bc3df444e373478dbc697be37277780
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 603fa59303b82d120b1afe8d2de49e4c5e5f10e063bef151570351ec1e11396ed82da2b52dcdae881b0722d4c9e5d9a409c4b8bdca4bbefc67aa9773ffd90532
|
7
|
+
data.tar.gz: 6e4d85f95b0d63eddb6d5eb6a730d439a807ffb726eabad15d4c3dbd31e2c6d6f2ddb51383ba9b43efccfee1eeb9f6b007debb471f65877688775a1444de9cdb
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
factory_strategist (0.
|
4
|
+
factory_strategist (0.3.0)
|
5
5
|
factory_bot
|
6
6
|
rspec
|
7
7
|
|
@@ -65,6 +65,7 @@ GEM
|
|
65
65
|
zeitwerk (2.4.2)
|
66
66
|
|
67
67
|
PLATFORMS
|
68
|
+
x86_64-darwin-19
|
68
69
|
x86_64-darwin-20
|
69
70
|
x86_64-linux
|
70
71
|
|
@@ -77,4 +78,4 @@ DEPENDENCIES
|
|
77
78
|
rubocop-rspec
|
78
79
|
|
79
80
|
BUNDLED WITH
|
80
|
-
2.2.
|
81
|
+
2.2.28
|
data/README.md
CHANGED
@@ -58,7 +58,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
58
58
|
|
59
59
|
## Contributing
|
60
60
|
|
61
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
61
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/neko314/factory_strategist. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/neko314/factory_strategist/blob/main/CODE_OF_CONDUCT.md).
|
62
62
|
|
63
63
|
## License
|
64
64
|
|
@@ -66,4 +66,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
66
66
|
|
67
67
|
## Code of Conduct
|
68
68
|
|
69
|
-
Everyone interacting in the FactoryStrategist project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/
|
69
|
+
Everyone interacting in the FactoryStrategist project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/neko314/factory_strategist/blob/main/CODE_OF_CONDUCT.md).
|
@@ -6,18 +6,33 @@ module FactoryStrategist
|
|
6
6
|
# Settings to see which method is best
|
7
7
|
module Configure
|
8
8
|
RSpec.configure do |config|
|
9
|
-
config.
|
10
|
-
|
11
|
-
end
|
12
|
-
|
13
|
-
config.after(:example) do |ex|
|
14
|
-
case ex.exception
|
15
|
-
when RSpec::Expectations::ExpectationNotMetError
|
16
|
-
# no-op
|
17
|
-
when nil
|
18
|
-
p "#{ex.location} create can be replaced to build_stubbed"
|
19
|
-
end
|
9
|
+
config.around(:example) do |ex|
|
10
|
+
detect_optimal_strategy_at(ex)
|
20
11
|
end
|
21
12
|
end
|
22
13
|
end
|
23
14
|
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def detect_optimal_strategy_at(example)
|
19
|
+
return unless run_successfully?(example) # when spec fails with create, no-op
|
20
|
+
|
21
|
+
return put_best_strategy_at(example, :build_stubbed) if run_successfully_with?(:build_stubbed, example)
|
22
|
+
|
23
|
+
put_best_strategy_at(example, :build) if run_successfully_with?(:build, example)
|
24
|
+
end
|
25
|
+
|
26
|
+
def run_successfully?(example)
|
27
|
+
example.run
|
28
|
+
!example.exception
|
29
|
+
end
|
30
|
+
|
31
|
+
def put_best_strategy_at(example, method)
|
32
|
+
p "#{example.location} create can be replaced to #{method}"
|
33
|
+
end
|
34
|
+
|
35
|
+
def run_successfully_with?(method, example)
|
36
|
+
FactoryBot::Syntax::Methods.alias_method :create, method
|
37
|
+
run_successfully?(example)
|
38
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: factory_strategist
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Keiko Kaneko
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: factory_bot
|