Skip to content
This repository has been archived by the owner on Jul 17, 2022. It is now read-only.

Latest commit

 

History

History
66 lines (53 loc) · 1.72 KB

README.md

File metadata and controls

66 lines (53 loc) · 1.72 KB

prefactory-example

An example rails application using Prefactory to accelerate spec execution time.

In this example, the FactoryGirl factory for creating a User has a synthetic 1 second latency injected per creation, to highlight the performance implications of repeat invocations of expensive factories and setup operation in specs, and the benefits of using Prefactory to mitigate those.

Diff showing the enabling and use of Prefactory in this example

Click to view diff

Expected behavior without using the Prefactory gem

$ git checkout not-using-prefactory

$ bundle exec rspec spec/models/user_spec.rb
Sleeping during create name: Jane Doe-1
.
Sleeping during create name: Jane Doe-2
Sleeping during create name: Jane Doe-3
Sleeping during create name: Jane Doe-4
.
Sleeping during create name: Jane Doe-5
Sleeping during create name: Jane Doe-6
.
Sleeping during create name: Jane Doe-7
Sleeping during create name: Jane Doe-8
.
Sleeping during create name: Jane Doe-9
Sleeping during create name: Jane Doe-10
Sleeping during create name: Jane Doe-11
.
Sleeping during create name: Jane Doe-12
Sleeping during create name: Jane Doe-13
.
Sleeping during create name: Jane Doe-14
Sleeping during create name: Jane Doe-15
.

Finished in 15.18 seconds
7 examples, 0 failures

Expected behavior with the Prefactory gem

$ git checkout master

$ bundle exec rspec spec/models/user_spec.rb
Sleeping during create name: Jane Doe-1
.
Sleeping during create name: Jane Doe-2
Sleeping during create name: Jane Doe-3
......

Finished in 3.1 seconds
7 examples, 0 failures