update readme and other things for upcoming release

This commit is contained in:
John Bintz 2011-11-23 17:57:19 -05:00
parent b420397349
commit 83e5bd542e
4 changed files with 27 additions and 99 deletions

View File

@ -2,9 +2,11 @@
Add running your Jasmine specs to your `Guardfile` via [`jasmine-headless-webkit`](http://github.com/johnbintz/jasmine-headless-webkit/). Nice!
``` ruby
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?
@ -18,14 +20,13 @@ home folder's `.jasmine-headless-webkit` file.
* `: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.
* All other options from `Jasmine::Headless::Runner`: (see the [list of available options](https://github.com/johnbintz/jasmine-headless-webkit/blob/master/lib/jasmine/headless/options.rb#L11A))
### Deprecated options
* `:run_before => "<command to run>"` to run a command before running specs. If the command fails, the test run stops.
## Using with .erb files in the Rails 3.1 Asset Pipeline and/or Jammit
## Using with Rails 3.1 and the Asset Pipeline and/or Jammit
Use [`guard-rails-assets`](https://github.com/dnagir/guard-rails-assets) chained in before `guard-jasmine-headless-webkit` to precompile your application
If your code required Jammit or ERB templates, which aren't directly supported by `jasmine-headledd-webkit`,
use [`guard-rails-assets`](https://github.com/dnagir/guard-rails-assets) chained in before `guard-jasmine-headless-webkit` to precompile your application
code for testing:
``` ruby
guard 'rails-assets' do
watch(%r{^app/assets/javascripts/.*})
end
@ -34,6 +35,7 @@ code for testing:
watch(%r{^public/assets/.*\.js})
... specs ...
end
```
Do the same for Jammit, using [`guard-jammit`](http://github.com/guard/guard-jammit).
@ -51,12 +53,3 @@ file is a little more complicated. `newest_js_file` extends the Guard DSL to sea
If you 100% know you won't need that support, modify your `Guardfile` as appropriate.
## ...and the `.jst` file search?
I use [Backbone.js](http://documentcloud.github.com/backbone/) a lot, and I put my Underscore view templates in `app/views/*.jst`
and mash them all together with [Jammit](https://github.com/documentcloud/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

View File

@ -26,8 +26,6 @@ module Guard
@filtered_options = options
DEFAULT_OPTIONS.keys.each { |key| @filtered_options.delete(key) }
UI.deprecation ":run_before is deprecated. Use guard-shell to do something beforehand. This will be removed in a future release." if @options[:run_before]
@files_to_rerun = []
end
@ -43,19 +41,13 @@ module Guard
def run_all
run_something_and_rescue do
@ran_before = false
run_for_failed_files if run_all_things_before
run_for_failed_files
end
end
def run_on_change(paths)
run_something_and_rescue do
paths = filter_paths(paths)
@ran_before = false
if run_all_things_before
@ran_before = true
if !paths.empty?
if !(paths = filter_paths(paths)).empty?
paths = (paths + @files_to_rerun).uniq
run_for_failed_files(paths)
@ -64,7 +56,6 @@ module Guard
end
end
end
end
private
def run_for_failed_files(paths = [])
@ -87,22 +78,6 @@ module Guard
%r{\.(#{@options[:valid_extensions].join('|')})$}
end
def run_before
run_a_thing_before(:run_before, @options[:run_before])
end
def run_a_thing_before(option, *args)
if @options[option] && !@ran_before
run_program(*args)
else
true
end
end
def run_all_things_before
run_before
end
def run_program(name, command = nil)
command ||= name
UI.info "Guard::JasmineHeadlessWebkit running #{name}..."

View File

@ -1,4 +1,4 @@
# Run JS and CoffeeScript files in a typical Rails 3.1 fashion, placing Underscore templates in app/views/*.jst
# Run JS and CoffeeScript files in a typical Rails 3.1/Sprockets fashion.
# Your spec files end with _spec.{js,coffee}.
spec_location = "spec/javascripts/%s_spec"
@ -7,9 +7,7 @@ spec_location = "spec/javascripts/%s_spec"
# spec_location = "spec/javascripts/%sSpec"
guard 'jasmine-headless-webkit' do
watch(%r{^app/views/.*\.jst$})
watch(%r{^public/javascripts/(.*)\.js$}) { |m| newest_js_file(spec_location % m[1]) }
watch(%r{^app/assets/javascripts/(.*)\.(js|coffee)$}) { |m| newest_js_file(spec_location % m[1]) }
watch(%r{^spec/javascripts/(.*)_spec\..*}) { |m| newest_js_file(spec_location % m[1]) }
watch(%r{^(app|lib|vendor)/assets/javascripts/(.*)$}) { |m| newest_js_file(spec_location % m[1]) }
watch(%r{^spec/javascripts/(.*)[Ss]pec\..*}) { |m| newest_js_file(spec_location % m[1]) }
end

View File

@ -23,15 +23,6 @@ describe Guard::JasmineHeadlessWebkit do
guard.start
end
end
context 'run_before' do
let(:options) { { :run_before => true, :all_on_start => false } }
it "should warn about deprecation" do
Guard::UI.expects(:deprecation).at_least_once
guard.start
end
end
end
describe '#run_all' do
@ -179,35 +170,6 @@ describe Guard::JasmineHeadlessWebkit do
end
end
context 'with run_before' do
context 'with failing command' do
before do
Guard::JasmineHeadlessWebkit::Runner.expects(:run).never
Guard::UI.expects(:info).with(regexp_matches(/false/))
end
let(:options) { { :run_before => 'false' } }
it "should run the command first" do
guard.run_all
end
end
context 'with succeeding command' do
before do
Guard::JasmineHeadlessWebkit::Runner.expects(:run).once
Guard::UI.expects(:info).with(regexp_matches(/true/))
Guard::UI.expects(:info).with(regexp_matches(/running all/))
end
let(:options) { { :run_before => 'true' } }
it "should run the command first" do
guard.run_all
end
end
end
describe '#reload' do
it 'should reset the state of the files_to_rerun' do
Guard::UI.expects(:info).with(regexp_matches(/Resetting/))