update readme and other things for upcoming release
This commit is contained in:
parent
b420397349
commit
83e5bd542e
41
README.md
41
README.md
@ -2,9 +2,11 @@
|
|||||||
|
|
||||||
Add running your Jasmine specs to your `Guardfile` via [`jasmine-headless-webkit`](http://github.com/johnbintz/jasmine-headless-webkit/). Nice!
|
Add running your Jasmine specs to your `Guardfile` via [`jasmine-headless-webkit`](http://github.com/johnbintz/jasmine-headless-webkit/). Nice!
|
||||||
|
|
||||||
guard 'jasmine-headless-webkit' do
|
``` ruby
|
||||||
watch(%r{^app/assets/javascripts/(.*)\..*}) { |m| newest_js_file("spec/javascripts/#{m[1]}_spec") }
|
guard 'jasmine-headless-webkit' do
|
||||||
end
|
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.
|
`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?
|
You should also put it in your `Gemfile` because, hey, why not, right?
|
||||||
@ -18,22 +20,22 @@ 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.
|
* `: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))
|
* 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
|
## Using with .erb files in the Rails 3.1 Asset Pipeline and/or Jammit
|
||||||
* `: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
|
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
|
||||||
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:
|
code for testing:
|
||||||
|
|
||||||
guard 'rails-assets' do
|
``` ruby
|
||||||
watch(%r{^app/assets/javascripts/.*})
|
guard 'rails-assets' do
|
||||||
end
|
watch(%r{^app/assets/javascripts/.*})
|
||||||
|
end
|
||||||
|
|
||||||
guard 'jasmine-headless-webkit' do
|
guard 'jasmine-headless-webkit' do
|
||||||
watch(%r{^public/assets/.*\.js})
|
watch(%r{^public/assets/.*\.js})
|
||||||
... specs ...
|
... specs ...
|
||||||
end
|
end
|
||||||
|
```
|
||||||
|
|
||||||
Do the same for Jammit, using [`guard-jammit`](http://github.com/guard/guard-jammit).
|
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.
|
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
|
|
||||||
|
|
||||||
|
@ -26,8 +26,6 @@ module Guard
|
|||||||
@filtered_options = options
|
@filtered_options = options
|
||||||
DEFAULT_OPTIONS.keys.each { |key| @filtered_options.delete(key) }
|
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 = []
|
@files_to_rerun = []
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -43,25 +41,18 @@ module Guard
|
|||||||
|
|
||||||
def run_all
|
def run_all
|
||||||
run_something_and_rescue do
|
run_something_and_rescue do
|
||||||
@ran_before = false
|
run_for_failed_files
|
||||||
|
|
||||||
run_for_failed_files if run_all_things_before
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def run_on_change(paths)
|
def run_on_change(paths)
|
||||||
run_something_and_rescue do
|
run_something_and_rescue do
|
||||||
paths = filter_paths(paths)
|
if !(paths = filter_paths(paths)).empty?
|
||||||
@ran_before = false
|
paths = (paths + @files_to_rerun).uniq
|
||||||
if run_all_things_before
|
|
||||||
@ran_before = true
|
|
||||||
if !paths.empty?
|
|
||||||
paths = (paths + @files_to_rerun).uniq
|
|
||||||
|
|
||||||
run_for_failed_files(paths)
|
run_for_failed_files(paths)
|
||||||
else
|
else
|
||||||
run_all
|
run_all
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -75,7 +66,7 @@ module Guard
|
|||||||
end
|
end
|
||||||
failed_files = Runner.run(paths, @filtered_options)
|
failed_files = Runner.run(paths, @filtered_options)
|
||||||
@files_to_rerun = failed_files || paths
|
@files_to_rerun = failed_files || paths
|
||||||
|
|
||||||
failed_files && @files_to_rerun.empty?
|
failed_files && @files_to_rerun.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -87,22 +78,6 @@ module Guard
|
|||||||
%r{\.(#{@options[:valid_extensions].join('|')})$}
|
%r{\.(#{@options[:valid_extensions].join('|')})$}
|
||||||
end
|
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)
|
def run_program(name, command = nil)
|
||||||
command ||= name
|
command ||= name
|
||||||
UI.info "Guard::JasmineHeadlessWebkit running #{name}..."
|
UI.info "Guard::JasmineHeadlessWebkit running #{name}..."
|
||||||
|
@ -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}.
|
# Your spec files end with _spec.{js,coffee}.
|
||||||
|
|
||||||
spec_location = "spec/javascripts/%s_spec"
|
spec_location = "spec/javascripts/%s_spec"
|
||||||
@ -7,9 +7,7 @@ spec_location = "spec/javascripts/%s_spec"
|
|||||||
# spec_location = "spec/javascripts/%sSpec"
|
# spec_location = "spec/javascripts/%sSpec"
|
||||||
|
|
||||||
guard 'jasmine-headless-webkit' do
|
guard 'jasmine-headless-webkit' do
|
||||||
watch(%r{^app/views/.*\.jst$})
|
watch(%r{^(app|lib|vendor)/assets/javascripts/(.*)$}) { |m| newest_js_file(spec_location % m[1]) }
|
||||||
watch(%r{^public/javascripts/(.*)\.js$}) { |m| newest_js_file(spec_location % m[1]) }
|
watch(%r{^spec/javascripts/(.*)[Ss]pec\..*}) { |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]) }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -23,15 +23,6 @@ describe Guard::JasmineHeadlessWebkit do
|
|||||||
guard.start
|
guard.start
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
||||||
describe '#run_all' do
|
describe '#run_all' do
|
||||||
@ -179,35 +170,6 @@ describe Guard::JasmineHeadlessWebkit do
|
|||||||
end
|
end
|
||||||
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
|
describe '#reload' do
|
||||||
it 'should reset the state of the files_to_rerun' do
|
it 'should reset the state of the files_to_rerun' do
|
||||||
Guard::UI.expects(:info).with(regexp_matches(/Resetting/))
|
Guard::UI.expects(:info).with(regexp_matches(/Resetting/))
|
||||||
|
Loading…
Reference in New Issue
Block a user