fixture_bot 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/README.md +9 -13
- data/lib/fixture_bot/fixture_creator.rb +1 -1
- 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: 55e1c0684eed79ec6b077d7e9459afec9aa884e47c999963aeef4f4914a3bee5
|
4
|
+
data.tar.gz: 8b856c48c24ec4567a5ed2cf5cdeda4d125ff94aad321822d65264319a501bf8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f4849de201e6c43a1b84d8043fe295cb137cbbc97d81eba1a4558f6c65bc930b00158842742af182fb1296ffbd6b8433715726cb7b97d172f8e68a3abf4e1ed3
|
7
|
+
data.tar.gz: daf184bd8d5e207a3b81bd1d5d0f8c621080de4dad20e5b33eb8a2ef7cdc5e5dfa7b0f28d4d079ba5cce71193247b4c7dce488dc170ef2e32a45f46be1722b52
|
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
|
```
|
@@ -63,7 +63,7 @@ module FixtureBot
|
|
63
63
|
private def fixture_with_id(table, name, &)
|
64
64
|
_, record_id = 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
68
|
SELECT setval(pg_get_serial_sequence('#{table}', 'id'), GREATEST(#{record_id}, nextval(pg_get_serial_sequence('#{table}', 'id'))))
|
69
69
|
SQL
|
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.3.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: 2024-
|
11
|
+
date: 2024-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|