guard-jasmine 1.19.2 → 2.0.0beta1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +31 -234
- data/lib/generators/guard_jasmine/install_generator.rb +17 -0
- data/lib/generators/guard_jasmine/templates/Guardfile +9 -0
- data/lib/guard/jasmine.rb +18 -15
- data/lib/guard/jasmine/cli.rb +5 -5
- data/lib/guard/jasmine/formatter.rb +10 -0
- data/lib/guard/jasmine/inspector.rb +1 -2
- data/lib/guard/jasmine/phantomjs/guard-jasmine.js +54 -180
- data/lib/guard/jasmine/phantomjs/guard-reporter.js +187 -0
- data/lib/guard/jasmine/phantomjs/src/guard-jasmine.coffee +101 -0
- data/lib/guard/jasmine/phantomjs/src/guard-reporter.coffee +109 -0
- data/lib/guard/jasmine/phantomjs/test/guard-reporter_spec.coffee +41 -0
- data/lib/guard/jasmine/runner.rb +178 -268
- data/lib/guard/jasmine/server.rb +17 -3
- data/lib/guard/jasmine/util.rb +1 -7
- data/lib/guard/jasmine/version.rb +1 -1
- metadata +135 -26
- data/lib/guard/jasmine/phantomjs/guard-jasmine.coffee +0 -193
- data/lib/guard/jasmine/phantomjs/lib/console.js +0 -188
- data/lib/guard/jasmine/phantomjs/lib/junit_reporter.js +0 -224
- data/lib/guard/jasmine/phantomjs/lib/reporter.js +0 -144
- data/lib/guard/jasmine/phantomjs/lib/result.js +0 -155
- data/lib/guard/jasmine/phantomjs/src/console.coffee +0 -149
- data/lib/guard/jasmine/phantomjs/src/reporter.coffee +0 -139
- data/lib/guard/jasmine/phantomjs/src/result.coffee +0 -95
- data/lib/guard/jasmine/phantomjs/test/console_spec.coffee +0 -125
- data/lib/guard/jasmine/phantomjs/test/reporter_spec.coffee +0 -0
- data/lib/guard/jasmine/phantomjs/test/result_spec.coffee +0 -311
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9852283136894ad3b639698821b88d26a08c89bb
|
4
|
+
data.tar.gz: 598808aead2bdce0f51ee5907bfaa0d44c503341
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 407fb6d9cdd446bd99f8aa457dffab5dc531b3ac30efb771147e2ff3a95c237e9ceb83279e0cf5688b4df94c44bc03f754ad46ab68037400bc1ad9bf475c9307
|
7
|
+
data.tar.gz: 0d0c99a86b87a430a3c93da08d7403c3aeeb5562fec6cc5b458cb78fdde521a810e734f5b638464a48d9ed771a4b081cbb57ff0350a9dccc1aa4e89aac620e92
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Guard::Jasmine [](http://travis-ci.org/guard/guard-jasmine)
|
2
2
|
|
3
3
|
Guard::Jasmine automatically tests your Jasmine specs when files are modified.
|
4
4
|
|
@@ -15,8 +15,8 @@ Ruby.
|
|
15
15
|
* Fast headless testing on [PhantomJS][], a full featured WebKit browser with native support for
|
16
16
|
various web standards: DOM handling, CSS selector, JSON, Canvas, and SVG.
|
17
17
|
|
18
|
-
* Runs the standard Jasmine test runner,
|
19
|
-
[Rails asset pipeline][]
|
18
|
+
* Runs the standard Jasmine test runner, which can optionally integrate [Jasmine][] into the
|
19
|
+
[Rails asset pipeline][], enabling you to write your specs in [CoffeeScript][].
|
20
20
|
|
21
21
|
* Integrates [Istanbul](https://github.com/gotwarlost/istanbul) to instrument your code in the asset pipeline and
|
22
22
|
generate coverage reports.
|
@@ -57,7 +57,7 @@ Add the default Guard::Jasmine template to your `Guardfile` by running:
|
|
57
57
|
$ guard init jasmine
|
58
58
|
```
|
59
59
|
|
60
|
-
Please have a look at the [CHANGELOG](https://github.com/
|
60
|
+
Please have a look at the [CHANGELOG](https://github.com/guard/guard-jasmine/blob/master/CHANGELOG.md) when
|
61
61
|
upgrading to a newer Guard::Jasmine version.
|
62
62
|
|
63
63
|
### PhantomJS
|
@@ -91,14 +91,14 @@ You can also build it from source for several other operating systems, please co
|
|
91
91
|
## Rails with the asset pipeline setup
|
92
92
|
|
93
93
|
With Rails 3.1 and later you can write your Jasmine specs in addition to JavaScript with CoffeeScript, fully integrated
|
94
|
-
into the Rails asset pipeline
|
94
|
+
into the Rails asset pipeline. You have full access to your running Rails app, but it's a good
|
95
95
|
practice to fake the server response. Check out the excellent [Sinon.JS][] documentation to learn more about this topic.
|
96
96
|
|
97
|
-
Guard::Jasmine will start a Rails Rack server to run your specs.
|
97
|
+
Guard::Jasmine will start a Rails Rack server to run your specs. Step by step instructions on configuring this are below.
|
98
98
|
|
99
99
|
### How it works
|
100
100
|
|
101
|
-

|
102
102
|
|
103
103
|
1. Guard is triggered by a file modification.
|
104
104
|
2. Guard::Jasmine executes the [PhantomJS script][].
|
@@ -111,228 +111,21 @@ Guard::Jasmine will start a Rails Rack server to run your specs.
|
|
111
111
|
9. The PhantomJS script collects the Jasmine runner results and returns a JSON report.
|
112
112
|
10. Guard::Jasmine reports the results to the console and system notifications.
|
113
113
|
|
114
|
-
|
114
|
+
#### Configuring Guard Jasmine to integrate with the asset pipeline.
|
115
115
|
|
116
|
-
|
116
|
+
* Install Guard Jasmine into the Rails project's Gemfile:
|
117
|
+
|
118
|
+
`gem "guard-jasmine", "~> 2.0"`
|
117
119
|
|
118
|
-
|
120
|
+
* Install Jasmine: `rails generate jasmine:install`
|
121
|
+
* (Optionally) install Jasmine examples: `rails generate jasmine:examples`
|
122
|
+
* (Optionally) Edit spec/javascripts/support/jasmine.yml to enable running CoffeeScript.
|
123
|
+
* Change the `spec_files:` section to `'**/*[sS]pec.{js,coffee}'`
|
124
|
+
* Install GuardJasmine's sample Guardfile `rails generate guard_jasmine:install`
|
125
|
+
* Run GuardJasmine: `guard`
|
126
|
+
|
127
|
+
A sample Rails project configured in this way is at https://github.com/nathanstitt/guard-jasmine-rails-test
|
119
128
|
|
120
|
-
```ruby
|
121
|
-
group :development, :test do
|
122
|
-
gem 'jasminerice'
|
123
|
-
end
|
124
|
-
```
|
125
|
-
|
126
|
-
And run following from the Terminal:
|
127
|
-
|
128
|
-
```bash
|
129
|
-
mkdir -p spec/javascripts
|
130
|
-
echo -e "#=require application\n#=require_tree ./" > spec/javascripts/spec.js.coffee
|
131
|
-
echo -e "/*\n *=require application\n */" > spec/javascripts/spec.css
|
132
|
-
```
|
133
|
-
|
134
|
-
This creates the directory `spec/javascripts` where your CoffeeScript tests goes into. You define the Rails
|
135
|
-
asset pipeline manifest in `spec/javascripts/spec.js.coffee`:
|
136
|
-
|
137
|
-
```coffeescript
|
138
|
-
#=require application
|
139
|
-
#=require_tree ./
|
140
|
-
```
|
141
|
-
|
142
|
-
It also creates an empty `spec/javascripts/spec.css` file as it is always requested when running specs.
|
143
|
-
|
144
|
-
Now you can access `/jasmine` when you start your Rails server normally.
|
145
|
-
|
146
|
-
### Jasmine-Rails
|
147
|
-
|
148
|
-
[jasmine-rails][] is another option for integrating your [Jasmine][] tests with an asset pipeline-enabled Rails application. The quick-and-dirty recipe for this is:
|
149
|
-
|
150
|
-
1. Add `jasmine-rails` to your `Gemfile`:
|
151
|
-
|
152
|
-
```ruby
|
153
|
-
group :test do
|
154
|
-
gem "jasmine-rails"
|
155
|
-
end
|
156
|
-
```
|
157
|
-
|
158
|
-
2. Configure a mount point in your application's `routes.rb` (please refer to the [jasmine-rails][] documentation for more details):
|
159
|
-
|
160
|
-
```ruby
|
161
|
-
mount JasmineRails::Engine => '/specs' if defined?(JasmineRails)
|
162
|
-
```
|
163
|
-
|
164
|
-
3. Configure **Guard::Jasmine** to reference the mount point in your `Guardfile`:
|
165
|
-
|
166
|
-
```ruby
|
167
|
-
guard 'jasmine', :server => :webrick, :server_mount => '/specs' do
|
168
|
-
# watch stuff
|
169
|
-
end
|
170
|
-
```
|
171
|
-
|
172
|
-
4. Profit! Seriously, you should be able to access the Jasmine runner at `/specs` within your Rails application, *and* **Guard::Jasmine** should run the same specs. Now no more excuses, get that javascript tested!
|
173
|
-
|
174
|
-
### Jasmine Stories acceptance tests
|
175
|
-
|
176
|
-
[Jasmine Stories](https://github.com/DominikGuzei/jasmine-stories) is a Jasminerice clone and that serves
|
177
|
-
[Jasmine-species](http://rudylattae.github.com/jasmine-species/) acceptance tests.
|
178
|
-
|
179
|
-
In short, you add it to your `Gemfile`:
|
180
|
-
|
181
|
-
```ruby
|
182
|
-
group :development, :test do
|
183
|
-
gem 'jasmine-stories'
|
184
|
-
end
|
185
|
-
```
|
186
|
-
|
187
|
-
And run following from the Terminal:
|
188
|
-
|
189
|
-
```bash
|
190
|
-
mkdir -p spec/javascripts/stories
|
191
|
-
echo -e "#=require_tree ./stories" > spec/javascripts/stories.js.coffee
|
192
|
-
echo -e "/*\n *=require application\n */" > spec/javascripts/spec.css
|
193
|
-
```
|
194
|
-
|
195
|
-
This creates the directory `spec/javascripts/stories` where your CoffeeScript acceptance tests goes into.
|
196
|
-
|
197
|
-
Now you can access `/jasmine-stories` when you start your Rails server normally. You have to change the Jasmine runner
|
198
|
-
accordingly:
|
199
|
-
|
200
|
-
```ruby
|
201
|
-
guard :jasmine, port: 8888, jasmine_url: 'http://127.0.0.1:8888/jasmine-stories' do
|
202
|
-
...
|
203
|
-
end
|
204
|
-
```
|
205
|
-
|
206
|
-
## Rails without the asset pipeline
|
207
|
-
|
208
|
-
With Rails without the asset pipeline or a plain Ruby project, you can use [the Jasmine Gem][] to configure your Jasmine
|
209
|
-
specs and server the Jasmine runner. You don't have full access to your running Rails app, but it's anyway a good
|
210
|
-
practice to fake the server response. Check out the excellent [Sinon.JS][] documentation to learn more about this topic.
|
211
|
-
|
212
|
-
Guard::Jasmine will start a Jasmine Gem Rack server to run your specs.
|
213
|
-
|
214
|
-
### How it works
|
215
|
-
|
216
|
-

|
217
|
-
|
218
|
-
1. Guard is triggered by a file modification.
|
219
|
-
2. Guard::Jasmine executes the [PhantomJS script][].
|
220
|
-
3. The PhantomJS script requests the Jasmine test runner via HTTP.
|
221
|
-
4. The Jasmine Gem reads your configuration and get the assets.
|
222
|
-
5. The Jasmine Gem serves the the code to be tested and the specs.
|
223
|
-
6. PhantomJS runs the Jasmine tests headless.
|
224
|
-
7. The PhantomJS script collects the Jasmine runner results and returns a JSON report.
|
225
|
-
8. Guard::Jasmine reports the results to the console and system notifications.
|
226
|
-
|
227
|
-
### Jasmine Gem
|
228
|
-
|
229
|
-
Please read the detailed installation and configuration instructions at [the Jasmine Gem][].
|
230
|
-
|
231
|
-
In short, you add the Jasmine gem to your `Gemfile`:
|
232
|
-
|
233
|
-
```ruby
|
234
|
-
group :development, :test do
|
235
|
-
gem 'jasmine'
|
236
|
-
end
|
237
|
-
```
|
238
|
-
|
239
|
-
and generate the configuration files.
|
240
|
-
|
241
|
-
#### Rails 3 without the asset pipeline
|
242
|
-
|
243
|
-
Install the Jasmine gem in your Rails 3 app with:
|
244
|
-
|
245
|
-
```bash
|
246
|
-
$ rails g jasmine:install
|
247
|
-
```
|
248
|
-
|
249
|
-
#### Rails 2
|
250
|
-
|
251
|
-
Install the Jasmine gem in your Rails 2 app with:
|
252
|
-
|
253
|
-
```bash
|
254
|
-
$ script/generate jasmine
|
255
|
-
```
|
256
|
-
|
257
|
-
Now you can configure your spec suite in the Jasmine configuration file `specs/javascripts/support/jasmine.yml`.
|
258
|
-
|
259
|
-
#### Writing CoffeeScript specs
|
260
|
-
|
261
|
-
It is also possible to use CoffeeScript in this setup, by using [Guard::CoffeeScript][] to compile your code and even
|
262
|
-
specs. Just add something like this *before* Guard::Jasmine:
|
263
|
-
|
264
|
-
```ruby
|
265
|
-
guard 'coffeescript', input: 'app/coffeescripts', output: 'public/javascripts'
|
266
|
-
guard 'coffeescript', input: 'spec/coffeescripts', output: 'spec/javascripts'
|
267
|
-
```
|
268
|
-
|
269
|
-
## Ruby projects
|
270
|
-
|
271
|
-
If you like to use Guard::Jasmine with a plain Ruby project, you can create a Rack configuration file
|
272
|
-
that starts a Rails instance with the asset pipeline and Jasminerice, having the full Rails testing
|
273
|
-
comfort for non-Rails projects. Please have a look at the
|
274
|
-
[Rails with the asset pipeline](https://github.com/netzpirat/guard-jasmine#rails-with-the-asset-pipeline-setup)
|
275
|
-
section to see how the setup works.
|
276
|
-
|
277
|
-
First you have the add the needed Gems to your `Gemfile`:
|
278
|
-
|
279
|
-
```Ruby
|
280
|
-
group :assets do
|
281
|
-
gem 'coffee-script'
|
282
|
-
end
|
283
|
-
|
284
|
-
group :development, :test do
|
285
|
-
gem 'actionpack', '~> 3.2'
|
286
|
-
gem 'railties', '~> 3.2'
|
287
|
-
gem 'tzinfo'
|
288
|
-
|
289
|
-
gem 'thin'
|
290
|
-
|
291
|
-
gem 'jasminerice'
|
292
|
-
gem 'jquery-rails'
|
293
|
-
gem 'guard-jasmine'
|
294
|
-
end
|
295
|
-
```
|
296
|
-
|
297
|
-
We add support for CoffeeScript specs, using Thin as spec server and adding Jasminerice and jQuery
|
298
|
-
(which is needed by Jasminerice) to the Gems. After installing the gems with `bundle`, we can
|
299
|
-
create a Rack configuration to spin up a mini-Rails app for testing:
|
300
|
-
|
301
|
-
```Ruby
|
302
|
-
require 'action_controller/railtie'
|
303
|
-
require 'jasminerice'
|
304
|
-
require 'guard/jasmine'
|
305
|
-
require 'sprockets/railtie'
|
306
|
-
require 'jquery-rails'
|
307
|
-
|
308
|
-
class JasmineTest < Rails::Application
|
309
|
-
routes.append do
|
310
|
-
mount Jasminerice::Engine, at: '/jasmine'
|
311
|
-
end
|
312
|
-
|
313
|
-
config.cache_classes = true
|
314
|
-
config.active_support.deprecation = :log
|
315
|
-
config.assets.enabled = true
|
316
|
-
config.assets.version = '1.0'
|
317
|
-
config.secret_token = '9696be98e32a5f213730cb7ed6161c79'
|
318
|
-
end
|
319
|
-
|
320
|
-
JasmineTest.initialize!
|
321
|
-
run JasmineTest
|
322
|
-
```
|
323
|
-
|
324
|
-
The mini Rails app is now ready to start and serve the Jasmine specs. You only have to create
|
325
|
-
`spec/javascripts/spec.js.coffee`, the Jasminerice asset pipeline manifest, and configure the
|
326
|
-
assets:
|
327
|
-
|
328
|
-
```CoffeeScript
|
329
|
-
#= require jquery
|
330
|
-
#= require_tree .
|
331
|
-
```
|
332
|
-
|
333
|
-
Start the test server manually with `bundle exec rackup -p 3000` and visit `http://localhost:3000/jasmine`
|
334
|
-
to verify it works. If everything is fine, you can continue with adding Guard::Jasmine to your `Guardfile`
|
335
|
-
and have your non-Rails app comfortably tested in a headless environment.
|
336
129
|
|
337
130
|
## Usage
|
338
131
|
|
@@ -378,7 +171,8 @@ server_env: :test # Jasmine server Rails environment
|
|
378
171
|
server_timeout: 30 # The number of seconds to wait for the Jasmine spec server
|
379
172
|
# default: 15
|
380
173
|
|
381
|
-
port: 8888 # Jasmine server port to use.
|
174
|
+
port: 8888 # Jasmine server port to use. Note that some ports (e.g. 6665) won't work.
|
175
|
+
# This is due to the fact that Webkit considers them unsafe.
|
382
176
|
# default: a random, free server port
|
383
177
|
|
384
178
|
phantomjs_bin: '~/bin/phantomjs' # Path to phantomjs.
|
@@ -805,7 +599,7 @@ I recommend to check out these other brilliant Jasmine runners:
|
|
805
599
|
|
806
600
|
## How to file an issue
|
807
601
|
|
808
|
-
You can report issues and feature requests to [GitHub Issues](https://github.com/
|
602
|
+
You can report issues and feature requests to [GitHub Issues](https://github.com/guard/guard-jasmine/issues). Try to figure out
|
809
603
|
where the issue belongs to: Is it an issue with Guard itself or with Guard::Jasmine? Please don't
|
810
604
|
ask question in the issue tracker, instead join us in our [Google group](http://groups.google.com/group/guard-dev) or on
|
811
605
|
`#guard` (irc.freenode.net).
|
@@ -821,7 +615,7 @@ When you file an issue, please try to follow to these simple rules if applicable
|
|
821
615
|
## Development information
|
822
616
|
|
823
617
|
- Documentation hosted at [RubyDoc](http://rubydoc.info/github/guard/guard-jasmine/master/frames).
|
824
|
-
- Source hosted at [GitHub](https://github.com/
|
618
|
+
- Source hosted at [GitHub](https://github.com/guard/guard-jasmine).
|
825
619
|
|
826
620
|
Pull requests are very welcome! Please try to follow these simple rules if applicable:
|
827
621
|
|
@@ -866,13 +660,16 @@ $ guard-jasmine-debug http://127.0.0.1:3000/Jasmine?spec=YourSpec
|
|
866
660
|
|
867
661
|
Developed by Michael Kessler, sponsored by [FlinkFinger](http://www.flinkfinger.com).
|
868
662
|
|
869
|
-
If you like Guard::Jasmine, you can watch the repository at [GitHub](https://github.com/
|
870
|
-
|
663
|
+
If you like Guard::Jasmine, you can watch the repository at [GitHub](https://github.com/guard/guard-jasmine).
|
664
|
+
|
665
|
+
## Maintainer
|
666
|
+
|
667
|
+
Maintained by [Nathan Stitt](https://github.com/nathanstitt).
|
871
668
|
|
872
669
|
## Contributors
|
873
670
|
|
874
|
-
See the [CHANGELOG](https://github.com/
|
875
|
-
[contributors](https://github.com/
|
671
|
+
See the [CHANGELOG](https://github.com/guard/guard-jasmine/blob/master/CHANGELOG.md) and the GitHub list of
|
672
|
+
[contributors](https://github.com/guard/guard-jasmine/contributors).
|
876
673
|
|
877
674
|
## Acknowledgment
|
878
675
|
|
@@ -889,7 +686,7 @@ for it!
|
|
889
686
|
|
890
687
|
(The MIT License)
|
891
688
|
|
892
|
-
Copyright (c) 2011-
|
689
|
+
Copyright (c) 2011-2014 Michael Kessler
|
893
690
|
|
894
691
|
Permission is hereby granted, free of charge, to any person obtaining
|
895
692
|
a copy of this software and associated documentation files (the
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
module GuardJasmine
|
4
|
+
class InstallGenerator < Rails::Generators::Base
|
5
|
+
desc "Install a sample Guardfile for running Jasmine specs via GuardJasmine"
|
6
|
+
|
7
|
+
def self.source_root
|
8
|
+
@source_root ||= File.join(File.dirname(__FILE__), 'templates')
|
9
|
+
end
|
10
|
+
|
11
|
+
# Generator Code. Remember this is just suped-up Thor so methods are executed in order
|
12
|
+
def install
|
13
|
+
template "Guardfile"
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
guard :jasmine do
|
5
|
+
watch(%r{^spec/javascripts/.*(?:_s|S)pec\.(coffee|js)$})
|
6
|
+
watch(%r{app/assets/javascripts/(.+?)\.(js\.coffee|js|coffee)(?:\.\w+)*$}) { |m|
|
7
|
+
"spec/javascripts/jasmine/#{ m[1] }_spec.#{ m[2] }"
|
8
|
+
}
|
9
|
+
end
|
data/lib/guard/jasmine.rb
CHANGED
@@ -18,7 +18,7 @@ module Guard
|
|
18
18
|
|
19
19
|
extend ::Guard::Jasmine::Util
|
20
20
|
|
21
|
-
attr_accessor :last_run_failed, :last_failed_paths, :run_all_options
|
21
|
+
attr_accessor :last_run_failed, :last_failed_paths, :run_all_options, :runner
|
22
22
|
|
23
23
|
DEFAULT_OPTIONS = {
|
24
24
|
server: :auto,
|
@@ -51,7 +51,8 @@ module Guard
|
|
51
51
|
lines_threshold: 0,
|
52
52
|
junit: false,
|
53
53
|
junit_consolidate: true,
|
54
|
-
junit_save_path: ''
|
54
|
+
junit_save_path: '',
|
55
|
+
debug: false
|
55
56
|
}
|
56
57
|
|
57
58
|
# Initialize Guard::Jasmine.
|
@@ -93,19 +94,20 @@ module Guard
|
|
93
94
|
options = DEFAULT_OPTIONS.merge(options)
|
94
95
|
|
95
96
|
options[:spec_dir] ||= File.exists?(File.join('spec', 'javascripts')) ? File.join('spec', 'javascripts') : 'spec'
|
96
|
-
options[:port] ||= Jasmine.find_free_server_port
|
97
97
|
options[:server] ||= :auto
|
98
|
-
options[:server]
|
98
|
+
options[:server] = ::Guard::Jasmine::Server.detect_server(options[:spec_dir]) if options[:server] == :auto
|
99
|
+
options[:port] ||= ::Guard::Jasmine::Server.choose_server_port(options)
|
99
100
|
options[:jasmine_url] = "http://localhost:#{ options[:port] }#{ options[:server] == :jasmine_gem ? '/' : options[:server_mount] }" unless options[:jasmine_url]
|
100
101
|
options[:specdoc] = :failure if ![:always, :never, :failure].include? options[:specdoc]
|
101
102
|
options[:phantomjs_bin] = Jasmine.which('phantomjs') unless options[:phantomjs_bin]
|
102
103
|
|
103
|
-
self.run_all_options = options.delete(:run_all) || {
|
104
|
+
self.run_all_options = options.delete(:run_all) || {}
|
104
105
|
|
105
106
|
super(options)
|
106
107
|
|
107
108
|
self.last_run_failed = false
|
108
109
|
self.last_failed_paths = []
|
110
|
+
@runner = Runner.new( options.merge(self.run_all_options) )
|
109
111
|
end
|
110
112
|
|
111
113
|
# Gets called once when Guard starts.
|
@@ -147,36 +149,37 @@ module Guard
|
|
147
149
|
# @raise [:task_has_failed] when run_all has failed
|
148
150
|
#
|
149
151
|
def run_all
|
150
|
-
|
152
|
+
results = runner.run([options[:spec_dir]])
|
151
153
|
|
152
|
-
self.last_failed_paths =
|
153
|
-
self.last_run_failed = !
|
154
|
+
self.last_failed_paths = results.keys
|
155
|
+
self.last_run_failed = !results.empty?
|
154
156
|
|
155
|
-
throw :task_has_failed
|
157
|
+
throw :task_has_failed if self.last_run_failed
|
156
158
|
end
|
157
|
-
|
158
159
|
# Gets called when watched paths and files have changes.
|
159
160
|
#
|
160
161
|
# @param [Array<String>] paths the changed paths and files
|
161
162
|
# @raise [:task_has_failed] when run_on_modifications has failed
|
162
163
|
#
|
163
164
|
def run_on_modifications(paths)
|
165
|
+
|
164
166
|
specs = options[:keep_failed] ? paths + self.last_failed_paths : paths
|
165
167
|
specs = Inspector.clean(specs, options) if options[:clean]
|
168
|
+
|
166
169
|
return false if specs.empty?
|
167
170
|
|
168
|
-
|
171
|
+
results = runner.run(specs)
|
169
172
|
|
170
|
-
if
|
173
|
+
if results.empty?
|
171
174
|
self.last_failed_paths = self.last_failed_paths - paths
|
172
175
|
run_all if self.last_run_failed && options[:all_after_pass]
|
173
176
|
else
|
174
|
-
self.last_failed_paths = self.last_failed_paths +
|
177
|
+
self.last_failed_paths = self.last_failed_paths + results.keys
|
175
178
|
end
|
176
179
|
|
177
|
-
self.last_run_failed = !
|
180
|
+
self.last_run_failed = !results.empty?
|
178
181
|
|
179
|
-
throw :task_has_failed
|
182
|
+
throw :task_has_failed if self.last_run_failed
|
180
183
|
end
|
181
184
|
|
182
185
|
end
|