Sample Rails PigCI Setup
This is a sample app for demonstrating how to setup the pig-ci-rails gem in your Ruby on Rails application, so you can monitor key metrics of your test suite.
Once setup, PigCI will monitor your app during when you run the test suite. Once the tests are complete it will output the key stats to terminal & to the /pig-ci
folder.
In terminal, run:
$ rails app:template LOCATION='https://railsbytes.com/script/Vdrswr'
Add the gem to your Gemfile:
group :test do
gem 'pig-ci-rails'
end
Ignore the pig-ci
folder, which is where metrics are saved for review after tests are ran by updating .gitignore
with:
# PigCI
/pig-ci
Update spec/rails_helper.rb
with the following:
require 'pig_ci'
PigCI.start do |config|
# Setup your thresholds if you don't like the defaults
# Maximum memory in megabytes
config.thresholds.memory = 300
# Maximum time per a HTTP request
config.thresholds.request_time = 200
# Maximum database calls per a request
config.thresholds.database_request = 15
end if RSpec.configuration.files_to_run.count > 1