When using Travis Pro we had five available executors, of which only two were being used, one by Jasmine and one by Rspec. This allows you to split your spec suite into multiple, but equal parts. We wanted to split our rspec suite into four parts to fully utilize our remaining executors.
This sped up our Travis Pro builds from running one travis process in 70 minutes to running four processes in 15 minutes each.
See the blog post about how we went about configuring this gem for Travis.
Add this line to your application's Gemfile:
gem 'rspec-parts'
And then execute:
$ bundle
Or install it yourself as:
$ gem install rspec-parts
Now you can run the following:
rake spec:part[1,4]
This will divide your specs into four equal parts, then run the first part of the four. rake spec:part[2,4]
will run the second part, and so on.
See the file .travis.example.yml for an example on how to configure travis to run these builds.
This gem should work pretty well with rspec. If you need to configure something, however, you must create the file spec/support/rspec-parts.rb
, and configure as below:
Rspec::Parts.configure do |config|
config.file_list_exclusions = ['spec/controllers/jasmine_fixture_generation/*.rb']
config.spec_directory_glob = 'spec/*'
config.rspec_opts = '--profile --tag ~nginx --format progress'
config.default_number_of_parts = 2
end
file_list_exclusions
will exclude the following files or directories from running.spec_directory_glob
allows you to choose which directories to includerspec_opts
allows you to tack on rspec options to therspec
command.default_number_of_parts
defaults to 4. This gets overridden by the second parameter in the commandrake spec:part[1,4]
but can be useful if you want to run a shortened version of the command:rake spec:part[1]
See the rspec_parts.rake
file for the usage of configuration variables.
After checking out the repo, run bin/setup
to install dependencies. Then, run rake spec
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and tags, and push the .gem
file to rubygems.org.
Bug reports and pull requests are welcome on GitHub at https://github.com/hjhart/rspec-parts. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
The gem is available as open source under the terms of the MIT License.