delta_test
It's kinda "delta update" for RSpec.
It basically do two things:
- Analyzes your tests and creates a dependencies table
- Based on the dependencies table and git diff,
only runs partial specs that are considered to be related to the file changes.
Setup
Installation
Add this line to your Gemfile:
gem 'delta_test'
Configuration
Create configuration file at your project root directory.
$ vi delta_test.yml
patterns:
- lib/**/*.rb
- app/**/*.rb
Rspec
Include delta_test in your spec/spec_helper.rb
.
require 'delta_test'
require 'delta_test/spec_helpers'
RSpec.configure do |config|
config.include DeltaTest::SpecHelpers
end
Usage
$ git clone git@example.com:sample/sample_stats.git tmp/delta_test_stats
$ delta_test stats:clean
$ delta_test exec rspec
$ delta_test stats:save
Advanced usage
Command
usage: delta_test <command> [--verbose] [<args>]
options:
--verbose Print more output.
commands:
exec [--force] <script> -- <files...>
Execute test script using delta_test.
--force to force DeltaTest to run full test in profile mode.
specs List related spec files for changes.
stats:clean Clean up temporary files.
stats:show Show dependencies table.
stats:save [--no-sync]
Save and sync a table file.
version Show version.
help Show this.
exec
example
RSpec command is rewritten to:
$ bundle exec rspec
↓
$ bundle exec delta_test exec rspec
With file lists:
$ bundle exec rspec spec/{models,controllers}
↓
$ bundle exec delta_test exec rspec -- spec/{models,controllers}
And to colorize RSpec outputs, use --tty
option of rspec
command:
$ bundle exec delta_test exec rspec --tty
Also delta_test supports parallel_tests:
$ bundle exec parallel_test -t rspec -n 4 spec/features
↓
$ bundle exec delta_test exec parallel_test -t rspec -n 4 -- spec/features
Configurations
stats_path: tmp/delta_test_stats
stats_life: 1000
full_test_patterns:
- Gemfile.lock
full_test_braches:
- master
patterns:
- lib/**/*.rb
- app/**/*.rb
exclude_patterns:
- lib/batch/*.rb
custom_mappings:
spec/features/i18n_spec.rb:
- config/locales/**/*.yml
Testing
Run units tests:
$ rake test # or you can use `rspec`
Run integration tests:
$ (cd spec/rails && bundle install)
$ rake rails:test
Contributing
Contributions are always welcome!
Bug reports
- Ensure the bug can be reproduced on the latest master
- Check it's not a duplicate
- Raise an issue
Pull requests
- Fork the repository
- Create a branch
- Write test-driven code
- Update the documentation if necessary
- Create a new pull request
License
This project is released under the MIT license. See LICENSE.txt
file for details.