A summary of data about the Ruby ecosystem.

https://github.com/guard/guard-rspec

Guard::RSpec automatically run your specs (much like autotest)
https://github.com/guard/guard-rspec

Keywords from Contributors

activerecord activejob mvc rspec rubygems crash-reporting rack rubocop devise code-formatter

Last synced: about 14 hours ago
JSON representation

Repository metadata

Guard::RSpec automatically run your specs (much like autotest)

README.md

Guard::RSpec

Gem Version Build Status Dependency Status Code Climate Coverage Status

Guard::RSpec allows to automatically & intelligently launch specs when files are modified.

  • Compatible with RSpec >2.99 & 3
  • Tested against Ruby 2.2.x, JRuby 9.0.5.0 and Rubinius.

Install

Add the gem to your Gemfile (inside development group):

 gem 'guard-rspec', require: false

Add guard definition to your Guardfile by running this command:

$ bundle exec guard init rspec

Installing with beta versions of RSpec

To install beta versions of RSpec, you need to set versions of all the dependencies, e.g:

gem 'rspec', '= 3.5.0.beta3'
gem 'rspec-core', '= 3.5.0.beta3'
gem 'rspec-expectations', '= 3.5.0.beta3'
gem 'rspec-mocks', '= 3.5.0.beta3'
gem 'rspec-support', '= 3.5.0.beta3'

gem 'guard-rspec', '~> 4.7'

and for Rails projects this also means adding:

gem 'rspec-rails', '= 3.5.0.beta3'

and then running bundle update rspec rspec-core rspec-expectations rspec-mocks rspec-support rspec-rails or just bundle update to update all the gems in your project.

Usage

Please read Guard usage doc.

Guardfile

Guard::RSpec can be adapted to all kinds of projects, some examples:

Standard RubyGem project

guard :rspec, cmd: 'rspec' do
  watch(%r{^spec/.+_spec\.rb$})
  watch(%r{^lib/(.+)\.rb$})     { |m| "spec/lib/#{m[1]}_spec.rb" }
  watch('spec/spec_helper.rb')  { "spec" }
end

Typical Rails app

guard :rspec, cmd: 'bundle exec rspec' do
  watch('spec/spec_helper.rb')                        { "spec" }
  watch('config/routes.rb')                           { "spec/routing" }
  watch('app/controllers/application_controller.rb')  { "spec/controllers" }
  watch(%r{^spec/.+_spec\.rb$})
  watch(%r{^app/(.+)\.rb$})                           { |m| "spec/#{m[1]}_spec.rb" }
  watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$})          { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
  watch(%r{^lib/(.+)\.rb$})                           { |m| "spec/lib/#{m[1]}_spec.rb" }
  watch(%r{^app/controllers/(.+)_(controller)\.rb$})  { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
end

Please read Guard doc for more information about the Guardfile DSL.

Options

Guard::RSpec 4.0 now uses a simpler approach with the new cmd option that let you precisely define which rspec command will be launched on each run. This option is required due to the number of different ways possible to invoke rspec, the template now includes a default that should work for most applications but may not be optimal for all. As example if you want to support Spring with a custom formatter (progress by default) use:

guard :rspec, cmd: 'spring rspec -f doc' do
  # ...
end

NOTE: the above example assumes you have the spring rspec command installed - see here: https://github.com/jonleighton/spring-commands-rspec

Running with bundler

Running bundle exec guard will not run the specs with bundler. You need to change the cmd option to bundle exec rspec:

guard :rspec, cmd: 'bundle exec rspec' do
  # ...
end

List of available options:

cmd: 'zeus rspec'      # Specify a custom rspec command to run, default: 'rspec'
cmd_additional_args: '-f progress' # Any arguments that should be added after the default
                                   # arguments are applied but before the spec list
spec_paths: ['spec']   # Specify a custom array of paths that contain spec files
failed_mode: :focus    # What to do with failed specs
                       # Available values:
                       #  :focus - focus on the first 10 failed specs, rerun till they pass
                       #  :keep - keep failed specs until they pass (add them to new ones)
                       #  :none (default) - just report
all_after_pass: true   # Run all specs after changed specs pass, default: false
all_on_start: true     # Run all the specs at startup, default: false
launchy: nil           # Pass a path to an rspec results file, e.g. ./tmp/spec_results.html
notification: false    # Display notification after the specs are done running, default: true
run_all: { cmd: 'custom rspec command', message: 'custom message' } # Custom options to use when running all specs
title: 'My project'    # Display a custom title for the notification, default: 'RSpec results'
chdir: 'directory'     # run rspec from within a given subdirectory (useful if project has separate specs for submodules)
results_file: 'some/path' # use the given file for storing results (instead of default relative path)
bundler_env: :original_env # Specify which Bundler env to run the cmd under, default: :original_env
                       # Available values:
                       #  :clean_env - old behavior, uses Bundler environment with all bundler-related variables removed. This is deprecated in bundler 1.12.x.
                       #  :original_env (default) - uses Bundler environment present before Bundler was activated
                       #  :inherit - runs inside the current environment

Using Launchy to view rspec results

guard-rspec can be configured to launch a results file in lieu of outputing rspec results to the terminal.
Configure your Guardfile with the launchy option:

guard :rspec, cmd: 'rspec -f html -o ./tmp/spec_results.html', launchy: './tmp/spec_results.html' do
  # ...
end

Zeus Integration

You can use plain Zeus or you can use Guard::Zeus for managing the Zeus server (but you'll want to remove the spec watchers from Guard::Zeus, or you'll have tests running multiple times).

Also, if you get warnings about empty environment, be sure to read about this workaround

Using parallel_tests

parallel_tests has a -o option for passing RSpec options, and here's a trick to make it work with Guard::RSpec:

rspec_options = {
  cmd: "bundle exec rspec",
  run_all: {
    cmd: "bundle exec parallel_rspec -o '",
    cmd_additional_args: "'"
  }
}
guard :rspec, rspec_options do
# (...)

(Notice where the ' characters are placed)

Development

Pull requests are very welcome! Please try to follow these simple rules if applicable:

  • Please create a topic branch for every separate change you make.
  • Make sure your patches are well tested. All specs run with rake spec:portability must pass.
  • Update the README.
  • Please do not change the version number.

For questions please join us in our Google group or on
#guard (irc.freenode.net).

Author

Thibaud Guillaume-Gentil (@thibaudgg)

Contributors

https://github.com/guard/guard-rspec/contributors


Owner metadata


GitHub Events

Total
Last Year

Committers metadata

Last synced: 1 day ago

Total Commits: 547
Total Committers: 101
Avg Commits per committer: 5.416
Development Distribution Score (DDS): 0.667

Commits in past year: 0
Committers in past year: 0
Avg Commits per committer in past year: 0.0
Development Distribution Score (DDS) in past year: 0.0

Name Email Commits
Thibaud Guillaume-Gentil t****d@t****e 182
Cezary Baginski c****y@c****t 93
Alexey Chernenkov l****e@p****t 32
Rémy Coutable r****i@r****e 17
Rémy Coutable r****e@g****m 12
Douglas Pouk d****g@m****m 11
Sam Saffron s****n@g****m 11
Ian MacLeod i****n@n****t 10
Rémy Coutable r****i@r****m 8
Hosam Aly h****y@a****g 7
Jade Meskill and Roy van de Water d****y@i****m 6
Chris Griego c****o@g****m 6
Jimmy Cuadra j****y@j****m 5
David Chelimsky d****y@g****m 5
Andre Arko a****e@a****t 5
Johannes Holzfuß D****h@w****e 5
Ash Moran a****n@p****k 4
Hedgehog h****s@g****m 4
Tyler Pickett t****6@g****m 4
slowjack2k s****r@g****e 3
Yuji Nakayama n****j@g****m 3
Andrew Nikolaev p****t@t****y 3
Daniel Grieve g****t@c****t 3
Artur Roszczyk a****k@g****m 3
Benjie Gillam b****e@j****m 3
David Wilkie d****e@g****m 3
Michael Kessler m****i@n****h 3
Shane Sveller s****r@g****m 3
Al Chou a****u@u****m 2
William t****a@g****m 2
and 71 more...

Committer domains:


Issue and Pull Request metadata

Last synced: 2 months ago

Total issues: 62
Total pull requests: 40
Average time to close issues: 3 months
Average time to close pull requests: 3 months
Total issue authors: 57
Total pull request authors: 33
Average comments per issue: 3.97
Average comments per pull request: 2.73
Merged pull request: 19
Bot issues: 0
Bot pull requests: 0

Past year issues: 1
Past year pull requests: 0
Past year average time to close issues: 7 days
Past year average time to close pull requests: N/A
Past year issue authors: 1
Past year pull request authors: 0
Past year average comments per issue: 0.0
Past year average comments per pull request: 0
Past year merged pull request: 0
Past year bot issues: 0
Past year bot pull requests: 0

More stats: https://issues.ecosyste.ms/repositories/lookup?url=https://github.com/guard/guard-rspec

Top Issue Authors

  • e2 (3)
  • dima4p (2)
  • marko-avlijas (2)
  • budmc29 (2)
  • dgmstuart (1)
  • KaoruDev (1)
  • davidalejandroaguilar (1)
  • 1v (1)
  • leemour (1)
  • flyingboy007 (1)
  • omarsotillo (1)
  • julie-ng (1)
  • rocknrollMarc (1)
  • ryankc33 (1)
  • tansaku (1)

Top Pull Request Authors

  • e2 (7)
  • kvokka (2)
  • rafasoares (1)
  • lucianosousa (1)
  • htanata (1)
  • HatemKhattab (1)
  • alex-tan (1)
  • agrberg (1)
  • ghost (1)
  • RobinDaugherty (1)
  • soberstadt (1)
  • vvlad (1)
  • wasimakram (1)
  • pocke (1)
  • A-Helberg (1)

Top Issue Labels

  • bug (6)
  • feature request (3)
  • zeus (1)
  • info needed (1)

Top Pull Request Labels


Package metadata

gem.coop: guard-rspec

Guard::RSpec automatically run your specs (much like autotest).

  • Homepage: https://github.com/guard/guard-rspec
  • Documentation: http://www.rubydoc.info/gems/guard-rspec/
  • Licenses: MIT
  • Latest release: 4.7.3 (published almost 10 years ago)
  • Last Synced: 2026-05-23T10:16:28.290Z (1 day ago)
  • Versions: 103
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 124,856,227 Total
  • Docker Downloads: 725,843,084
  • Rankings:
    • Dependent repos count: 0.0%
    • Dependent packages count: 0.0%
    • Average: 0.069%
    • Downloads: 0.208%
  • Maintainers (2)
rubygems.org: guard-rspec

Guard::RSpec automatically run your specs (much like autotest).

  • Homepage: https://github.com/guard/guard-rspec
  • Documentation: http://www.rubydoc.info/gems/guard-rspec/
  • Licenses: MIT
  • Latest release: 4.7.3 (published almost 10 years ago)
  • Last Synced: 2026-05-23T14:47:42.331Z (1 day ago)
  • Versions: 103
  • Dependent Packages: 4,640
  • Dependent Repositories: 59,105
  • Downloads: 124,857,705 Total
  • Docker Downloads: 725,843,084
  • Rankings:
    • Dependent packages count: 0.012%
    • Dependent repos count: 0.144%
    • Docker downloads count: 0.167%
    • Downloads: 0.212%
    • Average: 0.654%
    • Stargazers count: 1.65%
    • Forks count: 1.739%
  • Maintainers (2)

Dependencies

Gemfile rubygems
  • guard-compat >= 0.0.2 development
  • guard-rubocop >= 0 development
  • rspec ~> 3.4 development
  • rubocop >= 0 development
  • guard-rspec >= 0
guard-rspec.gemspec rubygems
  • guard ~> 2.1
  • guard-compat ~> 1.1
  • rspec >= 2.99.0, < 4.0

Score: 33.09317170563528