Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
This very simple gem reports on how FactoryGirl is being used during your test runs. This is useful in understanding where the time is going during your test runs; while FactoryGirl is useful, overuse can lead to serious slowdowns due to a cascade of database writes when building test objects. The analysis relies on the changes brought in with FactoryGirl 3.2
This gem is a developer utility and makes no effort to sanitize inputs or help you avoid making mistakes, but hopefully it's too simple to need much of that!
Add this line to your application's Gemfile:
gem 'factory_inspector'
And then execute:
$ bundle
Or install it yourself as:
$ gem install factory_inspector
FactoryInspector's API is just two methods; start_inspection
and generate_report
Assuming you're on a RSpec based project, the changes to your
spec/spec_helper.rb
file to introduce FactoryInspector would be:
require 'factory_inspector'
# From a project relative filename like 'log/filename.txt'
# generate the full path.
# TODO There must be simpler way to do this?
def get_project_path_for(filename)
"#{File.dirname(__FILE__)}/../#{filename}"
end
factory_inspector = FactoryInspector.new
RSpec.configure do |config|
config.before :suite do
factory_inspector.start_inspection
end
config.after :suite do
report_name = 'log/factory_inspector_report.txt'
report_path = get_project_path_for report_name
factory_inspector.generate_report report_path
puts "Factory Inspector report in '#{report_name}'"
end
end
After the tests have run, the nominated log file will have output similar to this:
FACTORY INSPECTOR - 46 FACTORIES USED
FACTORY NAME TOTAL OVERALL TIME PER LONGEST STRATEGIES
CALLS TIME (s) CALL (s) CALL (s)
school_with_terms 1 0.4783 0.47827 0.4783 [:create]
school_with_terms_and_cla 5 2.3859 0.47718 0.5184 [:create]
school_leaver 1 0.2581 0.25808 0.2581 [:create]
pre_enrolled_pupil 1 0.2570 0.25704 0.2570 [:create]
pupil_school_enrolment_fo 1 0.2008 0.20075 0.2008 [:build]
announcement 5 0.8973 0.17946 0.2327 [:create]
sub_class_with_pupils 5 0.7961 0.15921 0.2163 [:create, :build]
etc
git checkout -b my-new-feature
)git commit -am 'Added some feature'
)git push origin my-new-feature
)FAQs
Unknown package
We found that factory_inspector demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.