factory_bot-awesome_linter 0.0.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/factory_bot-awesome_linter.rb +29 -12
- data/lib/factory_bot-awesome_linter/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: 8740b68a3f7d66f034238f1c3873a02a665571de253901041a2855938d9d11e8
|
4
|
+
data.tar.gz: ad15e4c9237b2e764323ba7b30b9c1346159c36409889ebeffe15ddbdea9e95f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 22bd532a03b0b38b66d8f5d4de4acc509f19b76c18665efcdfaf37e311c2df5c43f2d273299757761015c24e94deec70959813ff960d6e8bc4cc6da0c569e2eb
|
7
|
+
data.tar.gz: 1705cf66aa84b8a8970080de648b129a4a3b8d4cb64efefe39b47cd2fdcc61953dde8e45566de27a57fdd71f93af39d6160b498f6c0854f5ea5a545920e51e7c
|
@@ -9,17 +9,11 @@ module FactoryBot
|
|
9
9
|
new(*args, **kwargs).lint!
|
10
10
|
end
|
11
11
|
|
12
|
-
def initialize(*args, strategy: :create, traits: false
|
13
|
-
|
14
|
-
@factories_to_lint = args[0]
|
15
|
-
else
|
16
|
-
FactoryBot.reload
|
17
|
-
@factories_to_lint = FactoryBot.factories
|
18
|
-
end
|
12
|
+
def initialize(*args, strategy: :create, traits: false)
|
13
|
+
@factories_to_lint = load_factories(*args)
|
19
14
|
|
20
15
|
@factory_strategy = strategy
|
21
16
|
@traits = traits
|
22
|
-
@verbose = verbose
|
23
17
|
@progress_bar = ProgressBar.create(format: "\e[0;32m %c/%C |%w>%i| %e \e[0m")
|
24
18
|
@invalid_factories = []
|
25
19
|
end
|
@@ -47,12 +41,35 @@ module FactoryBot
|
|
47
41
|
invalid_factories.empty?
|
48
42
|
end
|
49
43
|
|
44
|
+
def load_factories(*args)
|
45
|
+
p args
|
46
|
+
|
47
|
+
FactoryBot.reload
|
48
|
+
return FactoryBot.factories if args.empty?
|
49
|
+
|
50
|
+
args.flat_map do |arg|
|
51
|
+
case arg
|
52
|
+
when Symbol, String
|
53
|
+
FactoryBot.factories.find(arg)
|
54
|
+
when Regexp
|
55
|
+
FactoryBot.factories.select { |factory| factory.name.match?(arg) }
|
56
|
+
when FactoryBot::Factory
|
57
|
+
arg
|
58
|
+
else
|
59
|
+
raise TypeError, "unexpected argument: #{arg}"
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
50
64
|
def calculate_total
|
51
65
|
factories_to_lint.reduce(0) do |count, factory|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
66
|
+
if @traits
|
67
|
+
# Compile factory to count enum traits
|
68
|
+
factory.compile
|
69
|
+
count + 1 + factory.definition.defined_traits.size
|
70
|
+
else
|
71
|
+
count + 1
|
72
|
+
end
|
56
73
|
end
|
57
74
|
end
|
58
75
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: factory_bot-awesome_linter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Savater Sebastien
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-02-
|
11
|
+
date: 2021-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: factory_bot
|