factory_burgers 1.0.0 → 1.1.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_burgers/cheating.rb +1 -1
- data/lib/factory_burgers/factory_bot_adapter.rb +1 -1
- data/lib/factory_burgers/introspection.rb +3 -0
- data/lib/factory_burgers/middleware/build.rb +1 -1
- data/lib/factory_burgers/middleware/data.rb +5 -4
- data/lib/factory_burgers/models/factory.rb +15 -8
- data/lib/factory_burgers/version.rb +1 -1
- data/lib/factory_burgers.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7adfdace4f86d8ec2d39e60d0f0bb3b8863d1c189d0c6c6ed1a6b59047585b12
|
4
|
+
data.tar.gz: 183a11ba6d22a15fc1c245b805d16c22a5998f4923b80f9d0f769aefd62c0cb5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 560cd421fa2de822944d72420d1aa705595b7b3ce15a1193a7df4b426ce8d22fedec42728ee2b8a44ae5134995ec786aa6ec77203353f6ab5e38c5c23ec53261
|
7
|
+
data.tar.gz: 28703bd03c2cc1551ae1f4f9812bca12f38f3982c8155bab79d691614653afd36f0d400bbcb47ceb44bcacfd6b813110e6501cca0fa33e541c609480974b432c
|
@@ -36,7 +36,7 @@ module FactoryBurgers
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def find_highest_index_value(klass, column, sql, regex)
|
39
|
-
matches = klass.where(sql).pluck(column).
|
39
|
+
matches = klass.where(sql).pluck(column).grep(regex)
|
40
40
|
return matches.map { |value| value =~ regex && Regexp.last_match(1) }.map(&:to_i).max
|
41
41
|
end
|
42
42
|
|
@@ -23,6 +23,9 @@ module FactoryBurgers
|
|
23
23
|
def factories_for_class(klass)
|
24
24
|
factories.select do |factory|
|
25
25
|
factory.build_class.ancestors.include?(klass)
|
26
|
+
rescue NameError
|
27
|
+
# Some usages of factories include pseudo "abstract" factory parent classes that do not point to a real class
|
28
|
+
false
|
26
29
|
end
|
27
30
|
end
|
28
31
|
|
@@ -40,7 +40,7 @@ module FactoryBurgers
|
|
40
40
|
return [] if attribute_items.nil?
|
41
41
|
|
42
42
|
attribute_items = attribute_items.select { |attr| attr["name"].present? }
|
43
|
-
return attribute_items.
|
43
|
+
return attribute_items.to_h { |attr| [attr["name"], attr["value"]] }
|
44
44
|
end
|
45
45
|
|
46
46
|
def get_resource_owner(owner_type, owner_id)
|
@@ -5,13 +5,14 @@ module FactoryBurgers
|
|
5
5
|
# Respond with factory data to display in the main form
|
6
6
|
class Data
|
7
7
|
def call(*)
|
8
|
-
factories = FactoryBurgers.
|
9
|
-
|
8
|
+
factories = FactoryBurgers::Introspection.factories
|
9
|
+
models = factories.map { |factory| factory_model(factory) }.select(&:valid?)
|
10
|
+
factory_data = models.map(&:to_h)
|
10
11
|
return [200, {"Content-Type" => "application/json"}, [JSON.dump(factory_data)]]
|
11
12
|
end
|
12
13
|
|
13
|
-
def
|
14
|
-
FactoryBurgers::Models::Factory.new(factory)
|
14
|
+
def factory_model(factory)
|
15
|
+
FactoryBurgers::Models::Factory.new(factory)
|
15
16
|
end
|
16
17
|
end
|
17
18
|
end
|
@@ -12,6 +12,10 @@ module FactoryBurgers
|
|
12
12
|
@factory = factory
|
13
13
|
end
|
14
14
|
|
15
|
+
def valid?
|
16
|
+
build_class.present?
|
17
|
+
end
|
18
|
+
|
15
19
|
def to_h
|
16
20
|
{
|
17
21
|
name: name,
|
@@ -21,8 +25,8 @@ module FactoryBurgers
|
|
21
25
|
}
|
22
26
|
end
|
23
27
|
|
24
|
-
def to_json(
|
25
|
-
to_h.to_json(
|
28
|
+
def to_json(...)
|
29
|
+
to_h.to_json(...)
|
26
30
|
end
|
27
31
|
|
28
32
|
def name
|
@@ -45,6 +49,9 @@ module FactoryBurgers
|
|
45
49
|
|
46
50
|
def build_class
|
47
51
|
factory.build_class
|
52
|
+
rescue NameError
|
53
|
+
# Some usages of factories include pseudo "abstract" factory parent classes that do not point to a real class
|
54
|
+
nil
|
48
55
|
end
|
49
56
|
|
50
57
|
def settable_columns
|
@@ -56,7 +63,7 @@ module FactoryBurgers
|
|
56
63
|
end
|
57
64
|
end
|
58
65
|
|
59
|
-
|
66
|
+
# :nodoc:
|
60
67
|
class Attribute
|
61
68
|
attr_reader :column
|
62
69
|
|
@@ -68,8 +75,8 @@ module FactoryBurgers
|
|
68
75
|
{name: name}
|
69
76
|
end
|
70
77
|
|
71
|
-
def to_json(
|
72
|
-
to_h.to_json(
|
78
|
+
def to_json(...)
|
79
|
+
to_h.to_json(...)
|
73
80
|
end
|
74
81
|
|
75
82
|
def name
|
@@ -77,7 +84,7 @@ module FactoryBurgers
|
|
77
84
|
end
|
78
85
|
end
|
79
86
|
|
80
|
-
|
87
|
+
# :nodoc:
|
81
88
|
class Trait
|
82
89
|
attr_reader :trait
|
83
90
|
|
@@ -89,8 +96,8 @@ module FactoryBurgers
|
|
89
96
|
{name: name}
|
90
97
|
end
|
91
98
|
|
92
|
-
def to_json(
|
93
|
-
to_h.to_json(
|
99
|
+
def to_json(...)
|
100
|
+
to_h.to_json(...)
|
94
101
|
end
|
95
102
|
|
96
103
|
def name
|
data/lib/factory_burgers.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: factory_burgers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Schwartz
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-05-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: factory_bot
|
@@ -267,7 +267,7 @@ homepage: https://github.com/ozydingo/factory_burgers
|
|
267
267
|
licenses:
|
268
268
|
- MIT
|
269
269
|
metadata: {}
|
270
|
-
post_install_message:
|
270
|
+
post_install_message:
|
271
271
|
rdoc_options: []
|
272
272
|
require_paths:
|
273
273
|
- lib
|
@@ -282,8 +282,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
282
282
|
- !ruby/object:Gem::Version
|
283
283
|
version: '0'
|
284
284
|
requirements: []
|
285
|
-
rubygems_version: 3.
|
286
|
-
signing_key:
|
285
|
+
rubygems_version: 3.4.10
|
286
|
+
signing_key:
|
287
287
|
specification_version: 4
|
288
288
|
summary: Bring the power of thoughtbot/factory_bot to manual testing
|
289
289
|
test_files: []
|