Use Guard with jasmine-headless-webkit
Go to file
John Bintz 6e2be80d6a jhw uses full paths for everything now, this has to, too 2011-10-17 15:15:57 -04:00
lib/guard jhw uses full paths for everything now, this has to, too 2011-10-17 15:15:57 -04:00
script penchant-ize 2011-09-03 07:53:04 -04:00
spec clean some things up 2011-10-11 15:30:39 -04:00
.gitignore merge and add .orig to gitignore 2011-09-03 16:45:09 -04:00
Gemfile clean some things up 2011-10-11 15:30:39 -04:00
Guardfile support for faster filtered spec running in JHW 0.3.0 2011-06-10 11:33:27 -04:00
README.md some cleanups of running specs, ensure correct return values for serial guard execution 2011-09-07 09:53:33 -04:00
Rakefile clean some things up 2011-10-11 15:30:39 -04:00
guard-jasmine-headless-webkit.gemspec clean some things up 2011-10-11 15:30:39 -04:00

README.md

Guard support for jasmine-headless-webkit

Add running your Jasmine specs to your Guardfile via jasmine-headless-webkit. Nice!

guard 'jasmine-headless-webkit' do
  watch(%r{^app/assets/javascripts/(.*)\..*}) { |m| newest_js_file("spec/javascripts/#{m[1]}_spec") }
end

gem install guard-jasmine-headless-webkit and then guard init jasmine-headless-webkit in your project directory to get started. You should also put it in your Gemfile because, hey, why not, right?

Output is colored by default. If you want it not colored, place a --no-colors option into the project's or your home folder's .jasmine-headless-webkit file.

guard options

  • :all_on_start => false to not run everything when starting, just like guard-rspec.
  • :valid_extensions => %w{js coffee} to only trigger run_on_change events for files with these extensions. Forces Guard to re-run all tests when any other matched file changes.

Deprecated options

  • :run_before => "<command to run>" to run a command before running specs. If the command fails, the test run stops.

Using with Rails 3.1 and the Asset Pipeline and/or Jammit

Use guard-rails-assets chained in before guard-jasmine-headless-webkit to precompile your application code for testing:

guard 'rails-assets' do
  watch(%r{^app/assets/javascripts/.*})
end

guard 'jasmine-headless-webkit' do
  watch(%r{^public/assets/.*\.js})
  ... specs ...
end

Do the same for Jammit, using guard-jammit.

guard-jammit and Jammit >= 0.6.0

Jammit >= 0.6.0 changed how it determines the Rails environment. Use my fork of guard-jammit until it's fixed upstream.

What's the deal with newest_js_file?

Since one could, theoretically, have a CoffeeScript app file and a JavaScript spec file (or vice versa), the search for the correct matching file is a little more complicated. newest_js_file extends the Guard DSL to search the given path for the newest .js or .coffee file:

newest_js_file('spec/javascripts/models/my_model')
  #=> search for Dir['spec/javascripts/models/my_model*.{js,coffee}'] and return the newest file found

If you 100% know you won't need that support, modify your Guardfile as appropriate.

I use Backbone.js a lot, and I put my Underscore view templates in app/views/*.jst and mash them all together with Jammit for use in my apps. Feel free to change that, it's your Guardfile after all. Or, try it. It's easy to do in your assets.yml file:

templates:
- app/views/*.jst