factory_bot_instruments 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.rspec +2 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +165 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/factory_bot_instruments.gemspec +32 -0
- data/lib/factory_bot_instruments.rb +22 -0
- data/lib/factory_bot_instruments/benchmarking.rb +41 -0
- data/lib/factory_bot_instruments/tracing.rb +84 -0
- data/lib/factory_bot_instruments/version.rb +3 -0
- metadata +141 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 34d9d7992c8e4bcb920d0b65a79e03e6abbc3c91d700dc04078ce44528f871d2
|
4
|
+
data.tar.gz: 9fd18c2bc11f0f139718e6f03200a08e5c4d44dfa7b7ce68824d9594bec3c3f6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 29927122dcafce132d9b6513ef29d1b431e4adbe1182f5c671d65a25dfbf0ca3e1843e74a3f39b0b98caa7ee1893da35927bd551e720a481b29cc0dee8d8144d
|
7
|
+
data.tar.gz: e6a079d7ff7b4b2fede7ff86d40f058f6c32ddfbf3bb1deb863d989a2b7f929ec9b0e3b524bb3e8e2625649902816b805ac83eaa82e80f5450ca884a244a32bd
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at igor@renderedtext.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Igor Šarčević
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,165 @@
|
|
1
|
+
# Factory Bot Instruments
|
2
|
+
|
3
|
+
[![Build Status](https://semaphoreci.com/api/v1/shiroyasha/factory_girl_instruments/branches/master/badge.svg)](https://semaphoreci.com/shiroyasha/factory_girl_instruments)
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/factory_girl_instruments.svg)](https://badge.fury.io/rb/factory_girl_instruments)
|
5
|
+
|
6
|
+
Instruments for benchmarking, tracing, and debugging
|
7
|
+
[Factory Bot](https://github.com/thoughtbot/factory_bot) models.
|
8
|
+
|
9
|
+
Table of content:
|
10
|
+
|
11
|
+
- [Setup](#setup)
|
12
|
+
- [Benchmark one Factory](#benchmarking-one-factory-bot-model)
|
13
|
+
- [Benchmark all Factories](#benchmarking-all-factory-bot-models)
|
14
|
+
- [Trace Factory Bot calls](#tracing-factory-bot-calls)
|
15
|
+
|
16
|
+
## Purpose of this gem
|
17
|
+
|
18
|
+
Factory Bot is probably the base of your Rails test suite, but how deeply you
|
19
|
+
understand the models and the associations that are created in your tests?
|
20
|
+
|
21
|
+
Factory Bot Instruments help in these three aspects:
|
22
|
+
|
23
|
+
1. Slow test suites: Factory Bot is used for the bulk of tests in Rails. Even a
|
24
|
+
small performance improvement in one of your factories can dramatically
|
25
|
+
improve the speed of your overall test suite.
|
26
|
+
|
27
|
+
Hint: Run `FactoryBot.benchmark_all`.
|
28
|
+
|
29
|
+
2. Deeper understanding of the database state: By tracing factory bot and SQL
|
30
|
+
calls you can get a deeper understanding of what is actually created in your
|
31
|
+
tests, helping you to debug the issues faster.
|
32
|
+
|
33
|
+
Hint: Run `FactoryBot.trace { FactoryBot.create(:user) }`.
|
34
|
+
|
35
|
+
3. Find issues with missconfigured factories: When a factory is properly set up
|
36
|
+
it is a bliss to work with it. However, if there is a hidden deep in the
|
37
|
+
association chain debugging the created model can be a hellish experience.
|
38
|
+
|
39
|
+
Hint: Run `FactoryBot.trace { FactoryBot.create(:user) }` and observe the
|
40
|
+
chain of calls.
|
41
|
+
|
42
|
+
## Install
|
43
|
+
|
44
|
+
Add the following to your Gemfile:
|
45
|
+
|
46
|
+
```ruby
|
47
|
+
gem 'factory_bot_instruments'
|
48
|
+
```
|
49
|
+
|
50
|
+
and run `bundle install` from your shell.
|
51
|
+
|
52
|
+
To install the gem manually from your shell, run:
|
53
|
+
|
54
|
+
``` ruby
|
55
|
+
gem install factory_bot_instruments
|
56
|
+
```
|
57
|
+
|
58
|
+
## Documentation
|
59
|
+
|
60
|
+
### Benchmarking one Factory Bot model
|
61
|
+
|
62
|
+
If you have a `user` factory, you can benchmark it with:
|
63
|
+
|
64
|
+
``` ruby
|
65
|
+
FactoryBot.benchmark(:user)
|
66
|
+
```
|
67
|
+
|
68
|
+
By default, the `FactoryBot.create(<model>)` is called. You can pass `:method`
|
69
|
+
to override this:
|
70
|
+
|
71
|
+
``` ruby
|
72
|
+
FactoryBot.benchmark(:user, :method => :build_stubbed)
|
73
|
+
```
|
74
|
+
|
75
|
+
The above snippet will call `FactoryBot.build_stubbed(:user)`.
|
76
|
+
|
77
|
+
### Benchmarking all Factory Bot models
|
78
|
+
|
79
|
+
To collect benchmarking information from all Factory Bot models:
|
80
|
+
|
81
|
+
``` ruby
|
82
|
+
FactoryBot.benchmark_all
|
83
|
+
```
|
84
|
+
|
85
|
+
To skip a factory, pass the `:except` options:
|
86
|
+
|
87
|
+
``` ruby
|
88
|
+
FactoryBot.benchmark_all(:except => [:user])
|
89
|
+
```
|
90
|
+
|
91
|
+
By default, benchmarks for `FactoryBot.create(<model>)`,
|
92
|
+
`FactoryBot.build(<model>)`, `FactoryBot.build_stubbed(<model>)` are
|
93
|
+
collected. You can override this by passing an array of methods:
|
94
|
+
|
95
|
+
``` ruby
|
96
|
+
FactoryBot.benchmark_all(:methods => [:create]) # benchmark only :create
|
97
|
+
```
|
98
|
+
|
99
|
+
### Tracing Factory Bot calls
|
100
|
+
|
101
|
+
To trace factory Bot actions, wrap your call in the `FactoryBot.trace` method:
|
102
|
+
|
103
|
+
``` ruby
|
104
|
+
FactoryBot.trace do
|
105
|
+
FactoryBot.create(:comment)
|
106
|
+
end
|
107
|
+
```
|
108
|
+
|
109
|
+
The above snippet will output the following tree:
|
110
|
+
|
111
|
+
``` txt
|
112
|
+
┌ (start) create :comment
|
113
|
+
| ┌ (start) create :user
|
114
|
+
| | (0.1ms) begin transaction
|
115
|
+
| | (0.4ms) INSERT INTO "users" ("name", "username") VALUES (?, ?) [["name", "Peter Parker"], ["username", "spiderman"]]
|
116
|
+
| | (2.3ms) commit transaction
|
117
|
+
| └ (finish) create :user [0.010s]
|
118
|
+
| ┌ (start) create :article
|
119
|
+
| | ┌ (start) create :user
|
120
|
+
| | | (0.1ms) begin transaction
|
121
|
+
| | | (0.3ms) INSERT INTO "users" ("name", "username") VALUES (?, ?) [["name", "Peter Parker"], ["username", "spiderman"]]
|
122
|
+
| | | (1.8ms) commit transaction
|
123
|
+
| | └ (finish) create :user [0.007s]
|
124
|
+
| | (0.1ms) begin transaction
|
125
|
+
| | (0.2ms) INSERT INTO "articles" ("title", "content", "user_id") VALUES (?, ?, ?) [["title", "New Article"], ["content", "article content"], ["user_id", "121"]]
|
126
|
+
| | (1.5ms) commit transaction
|
127
|
+
| └ (finish) create :article [0.021s]
|
128
|
+
| (0.1ms) begin transaction
|
129
|
+
| (0.2ms) INSERT INTO "comments" ("content", "user_id", "article_id") VALUES (?, ?, ?) [["content", "First!"], ["user_id", "120"], ["article_id", "61"]]
|
130
|
+
| (1.5ms) commit transaction
|
131
|
+
└ (finish) create :comment [0.046s]
|
132
|
+
```
|
133
|
+
|
134
|
+
To trace without SQL logs, use the following:
|
135
|
+
|
136
|
+
``` ruby
|
137
|
+
FactoryBot.trace(sql: false) do
|
138
|
+
FactoryBot.create(:comment)
|
139
|
+
end
|
140
|
+
```
|
141
|
+
|
142
|
+
## Development
|
143
|
+
|
144
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then,
|
145
|
+
run `rake spec` to run the tests. You can also run `bin/console` for an
|
146
|
+
interactive prompt that will allow you to experiment.
|
147
|
+
|
148
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
149
|
+
To release a new version, update the version number in `version.rb`, and then
|
150
|
+
run `bundle exec rake release`, which will create a git tag for the version,
|
151
|
+
push git commits and tags, and push the `.gem` file
|
152
|
+
to [rubygems.org](https://rubygems.org).
|
153
|
+
|
154
|
+
## Contributing
|
155
|
+
|
156
|
+
Bug reports and pull requests are welcome on GitHub at
|
157
|
+
https://github.com/shiroyasha/factory_girl_instruments. This project is intended
|
158
|
+
to be a safe, welcoming space for collaboration, and contributors are expected
|
159
|
+
to adhere to the [Contributor Covenant](http://contributor-covenant.org) code
|
160
|
+
of conduct.
|
161
|
+
|
162
|
+
## License
|
163
|
+
|
164
|
+
The gem is available as open source under the terms of
|
165
|
+
the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "factory_bot_instruments"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'factory_bot_instruments/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "factory_bot_instruments"
|
8
|
+
spec.version = FactoryBotInstruments::VERSION
|
9
|
+
spec.authors = ["Igor Šarčević"]
|
10
|
+
spec.email = ["igor@renderedtext.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Instruments for Factory Bot}
|
13
|
+
spec.description = %q{Instruments for Factory Bot}
|
14
|
+
spec.homepage = "https://github.com/shiroyasha/factory_girl_instruments"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
19
|
+
end
|
20
|
+
|
21
|
+
spec.bindir = "exe"
|
22
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
|
+
spec.require_paths = ["lib"]
|
24
|
+
|
25
|
+
spec.add_dependency "factory_bot", "~> 4.5"
|
26
|
+
spec.add_dependency "activerecord", ">= 4.0"
|
27
|
+
|
28
|
+
spec.add_development_dependency "bundler", "~> 1.12"
|
29
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
30
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
31
|
+
spec.add_development_dependency "sqlite3"
|
32
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require "factory_bot_instruments/version"
|
2
|
+
|
3
|
+
require "factory_bot"
|
4
|
+
require "active_record"
|
5
|
+
|
6
|
+
require_relative "factory_bot_instruments/benchmarking"
|
7
|
+
require_relative "factory_bot_instruments/tracing"
|
8
|
+
|
9
|
+
FactoryBot.extend(FactoryBotInstruments::Benchmarking)
|
10
|
+
FactoryBot.extend(FactoryBotInstruments::Tracing)
|
11
|
+
|
12
|
+
module FactoryBotInstruments
|
13
|
+
|
14
|
+
def self.benchmark_report(options = {})
|
15
|
+
options = { :progress => true }.merge(options)
|
16
|
+
|
17
|
+
FactoryBot.benchmark_all(options).each do |benchmark|
|
18
|
+
puts benchmark
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module FactoryBotInstruments
|
2
|
+
module Benchmarking
|
3
|
+
def benchmark_all(
|
4
|
+
except: [],
|
5
|
+
methods: [:create, :build, :build_stubbed],
|
6
|
+
progress: false)
|
7
|
+
|
8
|
+
factories = FactoryBot.factories.map(&:name) - except
|
9
|
+
|
10
|
+
report = factories.map do |factory|
|
11
|
+
puts "Processing #{factory}" if progress
|
12
|
+
|
13
|
+
methods.map do |method|
|
14
|
+
benchmark(factory, :method => method)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
report.flatten.sort_by(&:duration)
|
19
|
+
end
|
20
|
+
|
21
|
+
def benchmark(factory, method: :create)
|
22
|
+
start = Time.now
|
23
|
+
|
24
|
+
ActiveRecord::Base.transaction do
|
25
|
+
FactoryBot.public_send(method, factory)
|
26
|
+
|
27
|
+
raise ActiveRecord::Rollback
|
28
|
+
end
|
29
|
+
|
30
|
+
Benchmark.new(factory, method, Time.now - start)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
Benchmark = Struct.new(:factory, :method, :duration) do
|
35
|
+
def to_s
|
36
|
+
formated_duration = format("%5.3fs", duration)
|
37
|
+
|
38
|
+
"#{formated_duration}: FactoryBot.#{method}(:#{factory})"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
$FACTORY_BOT_INSTRUMENTS_TRACING = false
|
2
|
+
$FACTORY_BOT_INSTRUMENTS_TRACING_DEPTH = 0
|
3
|
+
|
4
|
+
# monkey patch Factory#run
|
5
|
+
module FactoryBot
|
6
|
+
class Factory
|
7
|
+
alias_method :original_run, :run
|
8
|
+
|
9
|
+
def run(build_strategy, overrides, &block)
|
10
|
+
if $FACTORY_BOT_INSTRUMENTS_TRACING
|
11
|
+
depth = "| " * $FACTORY_BOT_INSTRUMENTS_TRACING_DEPTH
|
12
|
+
signature = "#{build_strategy} \e[32m:#{@name}\e[0m"
|
13
|
+
start = Time.now
|
14
|
+
|
15
|
+
puts "#{depth}┌ (start) #{signature}"
|
16
|
+
$FACTORY_BOT_INSTRUMENTS_TRACING_DEPTH += 1
|
17
|
+
end
|
18
|
+
|
19
|
+
result = original_run(build_strategy, overrides, &block)
|
20
|
+
|
21
|
+
if $FACTORY_BOT_INSTRUMENTS_TRACING
|
22
|
+
duration = format("%4.3fs", Time.now - start)
|
23
|
+
puts "#{depth}└ (finish) #{signature} [#{duration}]"
|
24
|
+
|
25
|
+
$FACTORY_BOT_INSTRUMENTS_TRACING_DEPTH -= 1
|
26
|
+
end
|
27
|
+
|
28
|
+
result
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
module FactoryBotInstruments
|
34
|
+
module TracingHelpers
|
35
|
+
def self.uncolorize(string)
|
36
|
+
string.gsub(/\033\[\d+m/, "")
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.sql_tracer(active)
|
40
|
+
return yield unless active
|
41
|
+
|
42
|
+
begin
|
43
|
+
stdout_log = Logger.new($stdout)
|
44
|
+
|
45
|
+
stdout_log.formatter = proc do |severity, datetime, progname, msg|
|
46
|
+
depth = "| " * ($FACTORY_BOT_INSTRUMENTS_TRACING_DEPTH - 1)
|
47
|
+
|
48
|
+
msg = FactoryBotInstruments::TracingHelpers.uncolorize(msg)
|
49
|
+
msg = msg.strip
|
50
|
+
msg = msg.gsub(/^SQL /, "") # remove SQL prefix
|
51
|
+
|
52
|
+
"#{depth}| \e[36m#{msg}\e[0m\n"
|
53
|
+
end
|
54
|
+
|
55
|
+
standard_logger = ActiveRecord::Base.logger
|
56
|
+
ActiveRecord::Base.logger = stdout_log
|
57
|
+
|
58
|
+
yield
|
59
|
+
ensure
|
60
|
+
ActiveRecord::Base.logger = standard_logger
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
module Tracing
|
66
|
+
def trace(sql: true)
|
67
|
+
result = nil
|
68
|
+
|
69
|
+
begin
|
70
|
+
$FACTORY_BOT_INSTRUMENTS_TRACING = true
|
71
|
+
$FACTORY_BOT_INSTRUMENTS_TRACING_DEPTH = 0
|
72
|
+
|
73
|
+
FactoryBotInstruments::TracingHelpers.sql_tracer(sql) do
|
74
|
+
result = yield
|
75
|
+
end
|
76
|
+
ensure
|
77
|
+
$FACTORY_BOT_INSTRUMENTS_TRACING = false
|
78
|
+
$FACTORY_BOT_INSTRUMENTS_TRACING_DEPTH = 0
|
79
|
+
end
|
80
|
+
|
81
|
+
result
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
metadata
ADDED
@@ -0,0 +1,141 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: factory_bot_instruments
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Igor Šarčević
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-02-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: factory_bot
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4.5'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '4.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: activerecord
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '4.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '4.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.12'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.12'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: sqlite3
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: Instruments for Factory Bot
|
98
|
+
email:
|
99
|
+
- igor@renderedtext.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".gitignore"
|
105
|
+
- ".rspec"
|
106
|
+
- CODE_OF_CONDUCT.md
|
107
|
+
- Gemfile
|
108
|
+
- LICENSE.txt
|
109
|
+
- README.md
|
110
|
+
- Rakefile
|
111
|
+
- bin/console
|
112
|
+
- bin/setup
|
113
|
+
- factory_bot_instruments.gemspec
|
114
|
+
- lib/factory_bot_instruments.rb
|
115
|
+
- lib/factory_bot_instruments/benchmarking.rb
|
116
|
+
- lib/factory_bot_instruments/tracing.rb
|
117
|
+
- lib/factory_bot_instruments/version.rb
|
118
|
+
homepage: https://github.com/shiroyasha/factory_girl_instruments
|
119
|
+
licenses:
|
120
|
+
- MIT
|
121
|
+
metadata: {}
|
122
|
+
post_install_message:
|
123
|
+
rdoc_options: []
|
124
|
+
require_paths:
|
125
|
+
- lib
|
126
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - ">="
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '0'
|
131
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
132
|
+
requirements:
|
133
|
+
- - ">="
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
version: '0'
|
136
|
+
requirements: []
|
137
|
+
rubygems_version: 3.0.6
|
138
|
+
signing_key:
|
139
|
+
specification_version: 4
|
140
|
+
summary: Instruments for Factory Bot
|
141
|
+
test_files: []
|