Skip to content

johan-carlsson/guard-test

 
 

Repository files navigation

Guard::Test

Test::Unit guard allows to automatically & intelligently launch tests when files are modified or created.

Compatibility

  • Compatible with Test::Unit ~> 2.2.
  • Tested on Ruby 1.8.7, REE and 1.9.2.

Install

Please be sure to have Guard installed before continue.

Install the gem:

gem install guard-test

Add it to your Gemfile (inside test group):

gem 'guard-test'

Add Guard definition to your Guardfile by running this command:

guard init test

Usage

Please read Guard usage doc.

Guardfile

Guard::Test can be adapted to many kind of projects.

Standard Ruby project

guard 'test' do
  watch(%r{lib/(.*)\.rb})      { |m| "test/#{m[1]}_test.rb" }
  watch(%r{test/.*_test\.rb})
  watch('test/test_helper.rb') { "test" }
end

Ruby On Rails project

guard 'test' do
  watch(%r{app/models/(.*)\.rb})                     { |m| "test/unit/#{m[1]}_test.rb" }
  watch(%r{app/controllers/(.*)\.rb})                { |m| "test/functional/#{m[1]}_test.rb" }
  watch(%r{app/views/.*\.rb})                        { "test/integration" }
  watch(%r{lib/(.*)\.rb})                            { |m| "test/#{m[1]}_test.rb" }
  watch(%r{test/.*_test.rb})
  watch('app/controllers/application_controller.rb') { ["test/functional", "test/integration"] }
  watch('test/test_helper.rb')                       { "test" }
end

Please read Guard doc for more info about Guardfile DSL.

Options

Guard::Test allows you to choose between two different runners (Guard::Test's runners are inherited from Test::Unit's console runner):

  • default: Display tests results as they happen, with different chars ('.' for pass, 'F' for fail, 'E' for error) and print failures/errors messages & backtraces when all the tests are finished. Obviously, this is the guard-test default.
  • fastfail: Display tests results as they happen and print failures/errors messages & backtraces immediately.

Available options:

:notify => false           # don't display Growl (or Libnotify) notification after the specs are done running, default: true
:runner => 'fastfail'      # default: 'default'
:bundler => false          # don't use "bundle exec" to run the test command, default: true if a you have a Gemfile
:rvm => ['1.8.7', '1.9.2'] # directly run your specs on multiple Rubies, default: nil
:verbose => true           # default: false

Set the desired options as follow method:

guard 'test', :runner => 'fastfail', :bundler => false, :rvm => ['1.8.7', 'ree'] do
  ...
end

Development

Pull requests are very welcome! Make sure your patches are well tested. Please create a topic branch for every separate change you make.

Versioning

Guard::Test follows Semantic Versioning, both SemVer and SemVerTag.

Author

Rémy Coutable

Kudos

Many thanks to Thibaud Guillaume-Gentil for creating the excellent Guard gem.

About

Guard::Test automatically run your tests (much like autotest)

Resources

License

Stars

Watchers

Forks

Packages

No packages published