fixture_bot 0.2.0 → 0.4.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/Gemfile +1 -1
- data/README.md +9 -13
- data/lib/fixture_bot/fixture_creator.rb +4 -4
- data/lib/fixture_bot/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: 5cab0a5ae780641030baa4e1e03344c11ae2c0b1335ba13d1811585dd0509425
|
4
|
+
data.tar.gz: 248ad2e7a4a6e50ea530d6f61087d27e30f5ddeaf68ce9e4f180bf3650ac35a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a9694e1cf5be46e6252e1c33fa36fbefb6e41f99ad7053355d4f5018540b130706b24fe1d971563068aa52328777abf69f7ea096c90c66ac22416dadde2bfd79
|
7
|
+
data.tar.gz: 8139af34d100047717de35b6c7595721f00138c76a802dac728d11ab78f4d797bbbc0eb7c2f050bb120a67b52d05f34eb278a3c86727ecccf9c769176daa1ebd
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -125,29 +125,25 @@ end
|
|
125
125
|
## Benchmarks
|
126
126
|
#### factories vs fixtures
|
127
127
|
|
128
|
-
simple model with 10 fields
|
129
128
|
```ruby
|
129
|
+
# simple model with 10 fields
|
130
130
|
Benchmark.ips do |x|
|
131
|
-
x.report("fixture") { brands(:lux) }. # fixture:
|
132
|
-
x.report("factory") { create(:brand) } # factory:
|
131
|
+
x.report("fixture") { brands(:lux) }. # fixture: 4666.2 i/s
|
132
|
+
x.report("factory") { create(:brand) } # factory: 1077.8 i/s - 4.33x slower
|
133
133
|
x.compare!
|
134
134
|
end
|
135
|
-
```
|
136
135
|
|
137
|
-
user model with 40+ fields, 1 association
|
138
|
-
```ruby
|
136
|
+
# user model with 40+ fields, 1 association
|
139
137
|
Benchmark.ips do |x|
|
140
|
-
x.report("fixture") { users(:with_post_index)} # fixture:
|
141
|
-
x.report("factory") { create(:user) } # factory:
|
138
|
+
x.report("fixture") { users(:with_post_index)} # fixture: 3395.4 i/s
|
139
|
+
x.report("factory") { create(:user) } # factory: 159.6 i/s - 21.27x slower
|
142
140
|
x.compare!
|
143
141
|
end
|
144
|
-
```
|
145
142
|
|
146
|
-
product model with 40+ fields, 5+ associations
|
147
|
-
```ruby
|
143
|
+
# product model with 40+ fields, 5+ associations
|
148
144
|
Benchmark.ips do |x|
|
149
|
-
x.report("fixture") { products(:available) } # fixture:
|
150
|
-
x.report("factory") { create(:product, :available) } # factory:
|
145
|
+
x.report("fixture") { products(:available) } # fixture: 3564.3 i/s
|
146
|
+
x.report("factory") { create(:product, :available) } # factory: 67.7 i/s - 52.68x slower
|
151
147
|
x.compare!
|
152
148
|
end
|
153
149
|
```
|
@@ -56,16 +56,16 @@ module FixtureBot
|
|
56
56
|
record_ids[table][name] ||=
|
57
57
|
begin
|
58
58
|
model = instance_eval(&)
|
59
|
-
[model.class.name, model.id]
|
59
|
+
[model.class.name, model.id, model.class.table_name]
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
63
|
private def fixture_with_id(table, name, &)
|
64
|
-
_, record_id = fixture(table, name, &)
|
64
|
+
_, record_id, db_table_name = fixture(table, name, &)
|
65
65
|
|
66
|
-
if ::ActiveRecord::Base.connection.
|
66
|
+
if ::ActiveRecord::Base.connection.respond_to?(:postgresql_version)
|
67
67
|
::ActiveRecord::Base.connection.execute <<~SQL
|
68
|
-
SELECT setval(pg_get_serial_sequence('#{
|
68
|
+
SELECT setval(pg_get_serial_sequence('#{db_table_name}', 'id'), GREATEST(#{record_id}, nextval(pg_get_serial_sequence('#{db_table_name}', 'id'))))
|
69
69
|
SQL
|
70
70
|
end
|
71
71
|
end
|
data/lib/fixture_bot/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fixture_bot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ermolaev Andrey
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-02-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|