RspecTimer
RSpecTimer will track the amount of time each of your tests take to complete, and when it's done, can save the data to a YAML file.
Installation
Add this line to your application's Gemfile:
gem 'rspec_timer'
And then execute:
$ bundle
Or install it yourself as:
$ gem install rspec_timer
Usage
In your spec_helper.rb file, set up your "around" and "after" hooks like so:
RSpec.configure do |config|
config.before(:suite) do
# Set the log file's path (optional - if not set, defaults
# to a 'rspec-metrics.yml' file in your current folder)
RspecTimer.log_file_path = 'rspec_metrics.yml'
# Completely wipes any metrics from the log (optional)
RspecTimer.wipe_stored_metrics
end
config.around(:each) do |example|
RspecTimer.run_and_measure(example)
end
config.after(:suite) do
# Output metrics after running the test suite
puts 'Metrics:'
puts RspecTimer.metrics.to_yaml.to_s
# Stores any metrics from this test run into the YAML log file
# Adds/updates metrics according to unique signatures which are generated
# using each individual test's line number and source code.
RspecTimer.save_metrics
end
end
Contributing
- Fork it ( https://github.com/tomchapin/rspec_timer/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request