{"id":13463356,"url":"https://github.com/guard/guard-rspec","last_synced_at":"2025-04-10T02:14:49.331Z","repository":{"id":1098800,"uuid":"959090","full_name":"guard/guard-rspec","owner":"guard","description":"Guard::RSpec automatically run your specs (much like autotest)","archived":false,"fork":false,"pushed_at":"2021-08-10T21:39:24.000Z","size":673,"stargazers_count":1317,"open_issues_count":49,"forks_count":246,"subscribers_count":23,"default_branch":"master","last_synced_at":"2025-04-02T14:24:54.096Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://rubygems.org/gems/guard-rspec","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/guard.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2010-10-03T21:10:16.000Z","updated_at":"2025-03-25T20:06:11.000Z","dependencies_parsed_at":"2022-08-16T12:00:44.584Z","dependency_job_id":null,"html_url":"https://github.com/guard/guard-rspec","commit_stats":null,"previous_names":[],"tags_count":104,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guard%2Fguard-rspec","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guard%2Fguard-rspec/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guard%2Fguard-rspec/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guard%2Fguard-rspec/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/guard","download_url":"https://codeload.github.com/guard/guard-rspec/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247229736,"owners_count":20905111,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T13:00:51.852Z","updated_at":"2025-04-10T02:14:49.307Z","avatar_url":"https://github.com/guard.png","language":"Ruby","readme":"# Guard::RSpec\n\n[![Gem Version](https://badge.fury.io/rb/guard-rspec.png)](http://badge.fury.io/rb/guard-rspec) [![Build Status](https://secure.travis-ci.org/guard/guard-rspec.png?branch=master)](http://travis-ci.org/guard/guard-rspec) [![Dependency Status](https://gemnasium.com/guard/guard-rspec.png)](https://gemnasium.com/guard/guard-rspec) [![Code Climate](https://codeclimate.com/github/guard/guard-rspec.png)](https://codeclimate.com/github/guard/guard-rspec) [![Coverage Status](https://coveralls.io/repos/guard/guard-rspec/badge.png?branch=master)](https://coveralls.io/r/guard/guard-rspec)\n\nGuard::RSpec allows to automatically \u0026 intelligently launch specs when files are modified.\n\n* Compatible with RSpec \u003e2.99 \u0026 3\n* Tested against Ruby 2.2.x, JRuby 9.0.5.0 ~~and Rubinius~~.\n\n## Install\n\nAdd the gem to your Gemfile (inside development group):\n\n``` ruby\n gem 'guard-rspec', require: false\n```\n\nAdd guard definition to your Guardfile by running this command:\n\n```\n$ bundle exec guard init rspec\n```\n\n## Installing with beta versions of RSpec\n\nTo install beta versions of RSpec, you need to set versions of all the dependencies, e.g:\n\n```ruby\ngem 'rspec', '= 3.5.0.beta3'\ngem 'rspec-core', '= 3.5.0.beta3'\ngem 'rspec-expectations', '= 3.5.0.beta3'\ngem 'rspec-mocks', '= 3.5.0.beta3'\ngem 'rspec-support', '= 3.5.0.beta3'\n\ngem 'guard-rspec', '~\u003e 4.7'\n```\n\nand for Rails projects this also means adding:\n\n```ruby\ngem 'rspec-rails', '= 3.5.0.beta3'\n```\n\nand 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.\n\n## Usage\n\nPlease read [Guard usage doc](https://github.com/guard/guard#readme).\n\n## Guardfile\n\nGuard::RSpec can be adapted to all kinds of projects, some examples:\n\n### Standard RubyGem project\n\n``` ruby\nguard :rspec, cmd: 'rspec' do\n  watch(%r{^spec/.+_spec\\.rb$})\n  watch(%r{^lib/(.+)\\.rb$})     { |m| \"spec/lib/#{m[1]}_spec.rb\" }\n  watch('spec/spec_helper.rb')  { \"spec\" }\nend\n```\n\n### Typical Rails app\n\n``` ruby\nguard :rspec, cmd: 'bundle exec rspec' do\n  watch('spec/spec_helper.rb')                        { \"spec\" }\n  watch('config/routes.rb')                           { \"spec/routing\" }\n  watch('app/controllers/application_controller.rb')  { \"spec/controllers\" }\n  watch(%r{^spec/.+_spec\\.rb$})\n  watch(%r{^app/(.+)\\.rb$})                           { |m| \"spec/#{m[1]}_spec.rb\" }\n  watch(%r{^app/(.*)(\\.erb|\\.haml|\\.slim)$})          { |m| \"spec/#{m[1]}#{m[2]}_spec.rb\" }\n  watch(%r{^lib/(.+)\\.rb$})                           { |m| \"spec/lib/#{m[1]}_spec.rb\" }\n  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\"] }\nend\n```\n\nPlease read [Guard doc](https://github.com/guard/guard#readme) for more information about the Guardfile DSL.\n\n## Options\n\nGuard::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:\n\n``` ruby\nguard :rspec, cmd: 'spring rspec -f doc' do\n  # ...\nend\n```\n\nNOTE: the above example assumes you have the `spring rspec` command installed - see here: https://github.com/jonleighton/spring-commands-rspec\n\n### Running with bundler\n\nRunning `bundle exec guard` will not run the specs with bundler. You need to change the `cmd` option to `bundle exec rspec`:\n\n``` ruby\nguard :rspec, cmd: 'bundle exec rspec' do\n  # ...\nend\n```\n\n### List of available options:\n\n``` ruby\ncmd: 'zeus rspec'      # Specify a custom rspec command to run, default: 'rspec'\ncmd_additional_args: '-f progress' # Any arguments that should be added after the default\n                                   # arguments are applied but before the spec list\nspec_paths: ['spec']   # Specify a custom array of paths that contain spec files\nfailed_mode: :focus    # What to do with failed specs\n                       # Available values:\n                       #  :focus - focus on the first 10 failed specs, rerun till they pass\n                       #  :keep - keep failed specs until they pass (add them to new ones)\n                       #  :none (default) - just report\nall_after_pass: true   # Run all specs after changed specs pass, default: false\nall_on_start: true     # Run all the specs at startup, default: false\nlaunchy: nil           # Pass a path to an rspec results file, e.g. ./tmp/spec_results.html\nnotification: false    # Display notification after the specs are done running, default: true\nrun_all: { cmd: 'custom rspec command', message: 'custom message' } # Custom options to use when running all specs\ntitle: 'My project'    # Display a custom title for the notification, default: 'RSpec results'\nchdir: 'directory'     # run rspec from within a given subdirectory (useful if project has separate specs for submodules)\nresults_file: 'some/path' # use the given file for storing results (instead of default relative path)\nbundler_env: :original_env # Specify which Bundler env to run the cmd under, default: :original_env\n                       # Available values:\n                       #  :clean_env - old behavior, uses Bundler environment with all bundler-related variables removed. This is deprecated in bundler 1.12.x.\n                       #  :original_env (default) - uses Bundler environment present before Bundler was activated\n                       #  :inherit - runs inside the current environment\n```\n\n### Using Launchy to view rspec results\n\nguard-rspec can be configured to launch a results file in lieu of outputing rspec results to the terminal.\nConfigure your Guardfile with the launchy option:\n\n``` ruby\nguard :rspec, cmd: 'rspec -f html -o ./tmp/spec_results.html', launchy: './tmp/spec_results.html' do\n  # ...\nend\n```\n\n### Zeus Integration\n\nYou 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).\n\nAlso, if you get warnings about empty environment, be sure to [read about this workaround](https://github.com/guard/guard-rspec/wiki/Warning:-no-environment)\n\n### Using parallel_tests\n\nparallel_tests has a `-o` option for passing RSpec options, and here's a trick to make it work with Guard::RSpec:\n\n```ruby\nrspec_options = {\n  cmd: \"bundle exec rspec\",\n  run_all: {\n    cmd: \"bundle exec parallel_rspec -o '\",\n    cmd_additional_args: \"'\"\n  }\n}\nguard :rspec, rspec_options do\n# (...)\n```\n\n(Notice where the `'` characters are placed)\n\n\n## Development\n\n* Documentation hosted at [RubyDoc](http://rubydoc.info/github/guard/guard-rspec/master/frames).\n* Source hosted at [GitHub](https://github.com/guard/guard-rspec).\n\nPull requests are very welcome! Please try to follow these simple rules if applicable:\n\n* Please create a topic branch for every separate change you make.\n* Make sure your patches are well tested. All specs run with `rake spec:portability` must pass.\n* Update the [README](https://github.com/guard/guard-rspec/blob/master/README.md).\n* Please **do not change** the version number.\n\nFor questions please join us in our [Google group](http://groups.google.com/group/guard-dev) or on\n`#guard` (irc.freenode.net).\n\n### Author\n\n[Thibaud Guillaume-Gentil](https://github.com/thibaudgg) ([@thibaudgg](https://twitter.com/thibaudgg))\n\n### Contributors\n\n[https://github.com/guard/guard-rspec/contributors](https://github.com/guard/guard-rspec/contributors)\n","funding_links":[],"categories":["Testing","Ruby"],"sub_categories":["Continuous Testing"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguard%2Fguard-rspec","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fguard%2Fguard-rspec","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguard%2Fguard-rspec/lists"}