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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 83f33524068913a52ed377f0ba677ddf8e669598a0d2a679ee939ee91d540120
4
- data.tar.gz: 0c5b55ccc8d6799c2f46f3cdb30630aa68e60300104e9b4499dd5317c8e0e88a
3
+ metadata.gz: a0ce7f02ee00b07efad3acb9b46edec6e555e6a271cb8cf380f4a7da0d447780
4
+ data.tar.gz: 3fefcdb5cdad957f34c19c5cb4cb36106bc3df444e373478dbc697be37277780
5
5
  SHA512:
6
- metadata.gz: f65c98e670a0e64af242e1c7ba4bf4e3c4ebf16a08457bcad97bf657f1b311ecae196f758e9b03587161d6ff26e72dacdbec1147d328425362495284788af743
7
- data.tar.gz: d545034207063763fcf086b92b2dccafa1aeaf1faf4ce736f31d6a50ff84341fa92b58ce551563c2b6284111761122248bbba777cb298380476ce565d7bae4bc
6
+ metadata.gz: 603fa59303b82d120b1afe8d2de49e4c5e5f10e063bef151570351ec1e11396ed82da2b52dcdae881b0722d4c9e5d9a409c4b8bdca4bbefc67aa9773ffd90532
7
+ data.tar.gz: 6e4d85f95b0d63eddb6d5eb6a730d439a807ffb726eabad15d4c3dbd31e2c6d6f2ddb51383ba9b43efccfee1eeb9f6b007debb471f65877688775a1444de9cdb
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.3.0] - 2021-10-03
4
+
5
+ - Rewrite main codes to make them simple(no specs!)
6
+
3
7
  ## [0.2.0] - 2021-09-26
4
8
 
5
9
  - Add environment variable: `FATORYSTRATEGIST` to apply configuration this gem expands
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- factory_strategist (0.1.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.26
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/[USERNAME]/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/[USERNAME]/factory_strategist/blob/main/CODE_OF_CONDUCT.md).
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/[USERNAME]/factory_strategist/blob/main/CODE_OF_CONDUCT.md).
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.before(:suite) do |_ex|
10
- FactoryBot::Syntax::Methods.alias_method :create, :build_stubbed
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FactoryStrategist
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.0"
5
5
  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.2.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-09-26 00:00:00.000000000 Z
11
+ date: 2021-10-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: factory_bot