2011-05-24 10:31:16 +00:00
|
|
|
# Guard support for jasmine-headless-webkit
|
2011-05-24 10:22:01 +00:00
|
|
|
|
|
|
|
Add running your Jasmine specs to your `Guardfile` via [`jasmine-headless-webkit`](http://github.com/johnbintz/jasmine-headless-webkit/). Nice!
|
2011-05-24 01:29:56 +00:00
|
|
|
|
|
|
|
guard 'jasmine-headless-webkit' do
|
2011-05-24 10:37:49 +00:00
|
|
|
watch(%r{^app/assets/javascripts/(.*)\..*}) { |m| newest_js_file("spec/javascripts/#{m[1]}_spec") }
|
2011-05-24 01:29:56 +00:00
|
|
|
end
|
|
|
|
|
2011-05-24 10:30:57 +00:00
|
|
|
`gem install guard-jasmine-headless-webkit` and then `guard init jasmine-headless-webkit` in your project directory to get started.
|
2011-05-24 10:43:39 +00:00
|
|
|
You should also put it in your `Gemfile` because, hey, why not, right?
|
2011-05-24 10:30:57 +00:00
|
|
|
|
2011-05-24 10:22:01 +00:00
|
|
|
## `guard` options
|
|
|
|
|
2011-05-24 10:31:37 +00:00
|
|
|
* `:all_on_start => false` to not run everything when starting, just like `guard-rspec`
|
2011-05-24 10:22:01 +00:00
|
|
|
|
|
|
|
## 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
|
2011-05-24 01:29:56 +00:00
|
|
|
|
2011-05-24 10:22:01 +00:00
|
|
|
If you 100% know you won't need that support, modify your `Guardfile` as appropriate.
|
2011-05-24 01:29:56 +00:00
|
|
|
|
2011-05-24 10:30:57 +00:00
|
|
|
## ...and the `.jst` file search?
|
|
|
|
|
|
|
|
I use Backbone.js a lot, and I put my 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.
|
|
|
|
|