Coder Social home page Coder Social logo

optionalg / guard-rspec Goto Github PK

View Code? Open in Web Editor NEW

This project forked from guard/guard-rspec

0.0 2.0 0.0 753 KB

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

Home Page: https://rubygems.org/gems/guard-rspec

License: MIT License

guard-rspec's Introduction

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.14
  • Tested against Ruby 1.9.3, 2.0.0, JRuby 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:

$ guard init rspec

Usage

Please read Guard usage doc.

Guardfile

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

Standard RubyGem project

guard :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 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 use now a more simple approach with the new cmd option that let you precisely define which rspec command will be launched on each run. 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

List of available options:

cmd: 'zeus rspec'      # specify a custom rpsec command to run, default: 'rspec'
spec_paths: ['spec']   # specify a custom array of paths that contain spec files
focus_on_failed: false # focus on the first 10 failed specs, rerun till they pass, default: true
keep_failed: true      # keep failed specs until they pass (add them to new ones), default: false
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.

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

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

guard-rspec's People

Contributors

thibaudgg avatar rymai avatar samsaffron avatar nevir avatar hosamaly avatar cgriego avatar indirect avatar ashmoran avatar jimmycuadra avatar hedgehog avatar sevos avatar dwilkie avatar netzpirat avatar shanesveller avatar kina avatar killphi avatar rspeicher avatar phallstrom avatar joshrieken avatar georgeguimaraes avatar derekprior avatar dpickett avatar hotfusionman avatar adrianartiles avatar vfrride avatar chocoby avatar y310 avatar yannlugrin avatar waldo avatar myronmarston avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.