Commit 25018521 authored by Sean Arnold's avatar Sean Arnold Committed by Mike Jang

Add Factory profiler to best practices documentation

parent 652e84b1
...@@ -64,6 +64,26 @@ Use [Factory Doctor](https://test-prof.evilmartians.io/#/profilers/factory_docto ...@@ -64,6 +64,26 @@ Use [Factory Doctor](https://test-prof.evilmartians.io/#/profilers/factory_docto
FDOC=1 bin/rspec spec/[path]/[to]/[spec].rb FDOC=1 bin/rspec spec/[path]/[to]/[spec].rb
``` ```
[Factory Profiler](https://test-prof.evilmartians.io/#/profilers/factory_prof) can help to identify unnecessary factory creation.
```shell
# run test for path
FPROF=1 bin/rspec spec/[path]/[to]/[spec].rb
# to visualize with a flamegraph
FPROF=flamegraph bin/rspec spec/[path]/[to]/[spec].rb
```
A common change is to use [`let_it_be`](#common-test-setup).
```ruby
# Old
let(:project) { create(:project) }
# New
let_it_be(:project) { create(:project) }
```
### General guidelines ### General guidelines
- Use a single, top-level `RSpec.describe ClassName` block. - Use a single, top-level `RSpec.describe ClassName` block.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment