guard-jasmine 1.3.0 → 1.19.2
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 +7 -0
- data/LICENSE +1 -1
- data/README.md +272 -93
- data/bin/guard-jasmine-debug +1 -1
- data/lib/guard/jasmine/cli.rb +180 -65
- data/lib/guard/jasmine/coverage.rb +69 -0
- data/lib/guard/jasmine/formatter.rb +3 -3
- data/lib/guard/jasmine/inspector.rb +1 -1
- data/lib/guard/jasmine/phantomjs/guard-jasmine.coffee +117 -34
- data/lib/guard/jasmine/phantomjs/guard-jasmine.js +246 -0
- data/lib/guard/jasmine/phantomjs/lib/console.js +9 -1
- data/lib/guard/jasmine/phantomjs/lib/junit_reporter.js +224 -0
- data/lib/guard/jasmine/phantomjs/lib/reporter.js +10 -3
- data/lib/guard/jasmine/phantomjs/lib/result.js +28 -1
- data/lib/guard/jasmine/phantomjs/src/reporter.coffee +6 -2
- data/lib/guard/jasmine/phantomjs/src/result.coffee +18 -2
- data/lib/guard/jasmine/runner.rb +382 -54
- data/lib/guard/jasmine/server.rb +106 -51
- data/lib/guard/jasmine/task.rb +1 -1
- data/lib/guard/jasmine/templates/Guardfile +4 -3
- data/lib/guard/jasmine/util.rb +33 -14
- data/lib/guard/jasmine/version.rb +1 -1
- data/lib/guard/jasmine.rb +75 -42
- metadata +42 -36
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 2023ac9b80d1f49f03e13afc24c7fa46348b41a1
|
|
4
|
+
data.tar.gz: 550ac8a2dde8bc3678692d7eb14bef40952f732e
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 5dfee71f3214204be61632de52ebd7c7a73757c2c368b7b11fd6e64945263910c907c11823e2f727c373e29cf1f20ec3828d0ca097670968f24cee46eb22dc7a
|
|
7
|
+
data.tar.gz: 2c879978c5f288890d1f92f2256b53772f83af2aee98cf3a87ae4fdebc91fbcb03e188645def29a436cf04f90070ca37449c75fff11999ab3ca311151a314832
|
data/LICENSE
CHANGED
data/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Guard::Jasmine automatically tests your Jasmine specs when files are modified.
|
|
4
4
|
|
|
5
|
-
Tested on MRI Ruby 1.
|
|
5
|
+
Tested on MRI Ruby 1.9.3, 2.0.0, 2.0.1 and the latest versions of JRuby and Rubinius.
|
|
6
6
|
|
|
7
7
|
If you have any questions please join us on our [Google group](http://groups.google.com/group/guard-dev) or on `#guard`
|
|
8
8
|
(irc.freenode.net).
|
|
@@ -15,9 +15,14 @@ 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, so you can use [Jasminerice][] for integrating [Jasmine][] into the
|
|
18
|
+
* Runs the standard Jasmine test runner, so you can use [Jasminerice][] or [jasmine-rails][] for integrating [Jasmine][] into the
|
|
19
19
|
[Rails asset pipeline][] and write your specs in [CoffeeScript][].
|
|
20
20
|
|
|
21
|
+
* Integrates [Istanbul](https://github.com/gotwarlost/istanbul) to instrument your code in the asset pipeline and
|
|
22
|
+
generate coverage reports.
|
|
23
|
+
|
|
24
|
+
* Custom console logger implementation for pretty printing JavaScript objects and DOM elements.
|
|
25
|
+
|
|
21
26
|
* Can be used to run [Jasmine-species](http://rudylattae.github.com/jasmine-species/) acceptance tests provided by
|
|
22
27
|
[Jasmine Stories](https://github.com/DominikGuzei/jasmine-stories).
|
|
23
28
|
|
|
@@ -25,6 +30,12 @@ various web standards: DOM handling, CSS selector, JSON, Canvas, and SVG.
|
|
|
25
30
|
|
|
26
31
|
* Runs on Mac OS X, Linux and Windows.
|
|
27
32
|
|
|
33
|
+
## ScreenCast
|
|
34
|
+
|
|
35
|
+
If you are a [RailsCast Pro](http://railscasts.com/pro) subscriber, I recommend to watch
|
|
36
|
+
[#261 Testing JavaScript with Jasmine (revised)](http://railscasts.com/episodes/261-testing-javascript-with-jasmine-revised)
|
|
37
|
+
for an introduction to Jasmine, Jasminerice and Guard::Jasmine.
|
|
38
|
+
|
|
28
39
|
## Installation
|
|
29
40
|
|
|
30
41
|
### Guard and Guard::Jasmine
|
|
@@ -60,7 +71,13 @@ Alternatively you can install [Homebrew][] on Mac OS X and install it with:
|
|
|
60
71
|
$ brew install phantomjs
|
|
61
72
|
```
|
|
62
73
|
|
|
63
|
-
If you are using Ubuntu
|
|
74
|
+
If you are using Ubuntu 12.04 or above, phantomjs is in the official repositories and can be installed with apt:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
$ sudo apt-get install phantomjs
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
For older versions of Ubuntu, you will need to add a repository first:
|
|
64
81
|
|
|
65
82
|
```bash
|
|
66
83
|
$ sudo add-apt-repository ppa:jerome-etienne/neoip
|
|
@@ -126,6 +143,34 @@ It also creates an empty `spec/javascripts/spec.css` file as it is always reques
|
|
|
126
143
|
|
|
127
144
|
Now you can access `/jasmine` when you start your Rails server normally.
|
|
128
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
|
+
|
|
129
174
|
### Jasmine Stories acceptance tests
|
|
130
175
|
|
|
131
176
|
[Jasmine Stories](https://github.com/DominikGuzei/jasmine-stories) is a Jasminerice clone and that serves
|
|
@@ -153,7 +198,7 @@ Now you can access `/jasmine-stories` when you start your Rails server normally.
|
|
|
153
198
|
accordingly:
|
|
154
199
|
|
|
155
200
|
```ruby
|
|
156
|
-
guard :jasmine, :jasmine_url
|
|
201
|
+
guard :jasmine, port: 8888, jasmine_url: 'http://127.0.0.1:8888/jasmine-stories' do
|
|
157
202
|
...
|
|
158
203
|
end
|
|
159
204
|
```
|
|
@@ -191,13 +236,7 @@ group :development, :test do
|
|
|
191
236
|
end
|
|
192
237
|
```
|
|
193
238
|
|
|
194
|
-
and generate the configuration files
|
|
195
|
-
|
|
196
|
-
```ruby
|
|
197
|
-
guard :jasmine, :jasmine_url => 'http://localhost:8888/' do
|
|
198
|
-
...
|
|
199
|
-
end
|
|
200
|
-
```
|
|
239
|
+
and generate the configuration files.
|
|
201
240
|
|
|
202
241
|
#### Rails 3 without the asset pipeline
|
|
203
242
|
|
|
@@ -223,8 +262,8 @@ It is also possible to use CoffeeScript in this setup, by using [Guard::CoffeeSc
|
|
|
223
262
|
specs. Just add something like this *before* Guard::Jasmine:
|
|
224
263
|
|
|
225
264
|
```ruby
|
|
226
|
-
guard 'coffeescript', :
|
|
227
|
-
guard 'coffeescript', :
|
|
265
|
+
guard 'coffeescript', input: 'app/coffeescripts', output: 'public/javascripts'
|
|
266
|
+
guard 'coffeescript', input: 'spec/coffeescripts', output: 'spec/javascripts'
|
|
228
267
|
```
|
|
229
268
|
|
|
230
269
|
## Ruby projects
|
|
@@ -260,15 +299,15 @@ We add support for CoffeeScript specs, using Thin as spec server and adding Jasm
|
|
|
260
299
|
create a Rack configuration to spin up a mini-Rails app for testing:
|
|
261
300
|
|
|
262
301
|
```Ruby
|
|
263
|
-
require '
|
|
264
|
-
require 'rails/all'
|
|
302
|
+
require 'action_controller/railtie'
|
|
265
303
|
require 'jasminerice'
|
|
304
|
+
require 'guard/jasmine'
|
|
266
305
|
require 'sprockets/railtie'
|
|
267
306
|
require 'jquery-rails'
|
|
268
307
|
|
|
269
308
|
class JasmineTest < Rails::Application
|
|
270
309
|
routes.append do
|
|
271
|
-
mount Jasminerice::Engine
|
|
310
|
+
mount Jasminerice::Engine, at: '/jasmine'
|
|
272
311
|
end
|
|
273
312
|
|
|
274
313
|
config.cache_classes = true
|
|
@@ -318,7 +357,7 @@ There are many options that can customize Guard::Jasmine to your needs. Options
|
|
|
318
357
|
defining the Guard in your `Guardfile`:
|
|
319
358
|
|
|
320
359
|
```ruby
|
|
321
|
-
guard 'jasmine', :
|
|
360
|
+
guard 'jasmine', all_on_start: false, specdoc: :always do
|
|
322
361
|
...
|
|
323
362
|
end
|
|
324
363
|
```
|
|
@@ -328,33 +367,40 @@ end
|
|
|
328
367
|
The server options configures the server environment that is needed to run Guard::Jasmine:
|
|
329
368
|
|
|
330
369
|
```ruby
|
|
331
|
-
|
|
332
|
-
# :webrick, :mongrel, :thin, :jasmine_gem
|
|
370
|
+
server: :jasmine_gem # Jasmine server to use, either :auto, :none,
|
|
371
|
+
# :webrick, :mongrel, :thin, :unicorn, :jasmine_gem, :puma
|
|
333
372
|
# default: :auto
|
|
334
373
|
|
|
335
|
-
|
|
374
|
+
server_env: :test # Jasmine server Rails environment to set,
|
|
336
375
|
# e.g. :development or :test
|
|
337
|
-
# default: :development
|
|
376
|
+
# default: RAILS_ENV is exists, otherwise :development
|
|
338
377
|
|
|
339
|
-
:
|
|
340
|
-
# default:
|
|
378
|
+
server_timeout: 30 # The number of seconds to wait for the Jasmine spec server
|
|
379
|
+
# default: 15
|
|
341
380
|
|
|
342
|
-
:
|
|
381
|
+
port: 8888 # Jasmine server port to use.
|
|
382
|
+
# default: a random, free server port
|
|
383
|
+
|
|
384
|
+
phantomjs_bin: '~/bin/phantomjs' # Path to phantomjs.
|
|
343
385
|
# default: auto-detect 'phantomjs'
|
|
344
386
|
|
|
345
|
-
:
|
|
346
|
-
# default:
|
|
387
|
+
timeout: 20 # The time in seconds to wait for the spec runner to finish.
|
|
388
|
+
# default: 10
|
|
389
|
+
|
|
390
|
+
rackup_config: 'spec/dummy/config.ru' # Path to rackup config file (i.e. for webrick, mongrel, thin, unicorn, puma).
|
|
391
|
+
# default: ./config.ru
|
|
392
|
+
# This option is useful when using guard-jasmine in a mountable engine
|
|
393
|
+
# and the config.ru is within the dummy app
|
|
347
394
|
```
|
|
348
395
|
|
|
349
|
-
If you're setting the `:server` option to `:none
|
|
396
|
+
If you're setting the `:server` option to `:none` or need to access your specs on a other host than `localhost`, you can
|
|
397
|
+
supply the Jasmine runner url manually:
|
|
350
398
|
|
|
351
399
|
```ruby
|
|
352
|
-
:
|
|
353
|
-
|
|
400
|
+
jasmine_url: 'http://192.168.1.5:1234/jasmine' # URL where Jasmine is served.
|
|
401
|
+
# default: nil
|
|
354
402
|
```
|
|
355
|
-
|
|
356
|
-
Detecting the server with the `auto` option does only detect the jasmine gem or webrick. If you want to use mongrel or
|
|
357
|
-
thins, you have to set it explicit in the server option.
|
|
403
|
+
You may want to have also a fixed port instead of the random generated one.
|
|
358
404
|
|
|
359
405
|
The reason why the Server environment is set to `development` by default is that in development mode
|
|
360
406
|
the asset pipeline doesn't concatenate the JavaScripts and you'll see the line number in the real file,
|
|
@@ -364,7 +410,7 @@ instead of a ridiculous high line number in a single, very large JavaScript.
|
|
|
364
410
|
|
|
365
411
|
If you supply an unknown server name as the `:server` option, then Guard::Jasmine will execute
|
|
366
412
|
a `rake` task with the given server name as task in a child process. For example, if you configure
|
|
367
|
-
|
|
413
|
+
`server: 'start_my_server'`, then the command `rake start_my_server` will be executed and
|
|
368
414
|
you have to make sure the server starts on the port that you can get from the `JASMINE_PORT`
|
|
369
415
|
environment variable.
|
|
370
416
|
|
|
@@ -373,19 +419,19 @@ environment variable.
|
|
|
373
419
|
The spec runner options configures the behavior driven development (or BDD) cycle:
|
|
374
420
|
|
|
375
421
|
```ruby
|
|
376
|
-
:
|
|
422
|
+
spec_dir: 'app/spec' # Directory with the Jasmine specs.
|
|
377
423
|
# default: 'spec/javascripts'
|
|
378
424
|
|
|
379
|
-
:
|
|
425
|
+
clean: false # Clean the spec list by only keep Jasmine specs within the project.
|
|
380
426
|
# default: true
|
|
381
427
|
|
|
382
|
-
:
|
|
428
|
+
all_on_start: false # Run all suites on start.
|
|
383
429
|
# default: true
|
|
384
430
|
|
|
385
|
-
:
|
|
431
|
+
keep_failed: false # Keep failed suites and add them to the next run again.
|
|
386
432
|
# default: true
|
|
387
433
|
|
|
388
|
-
:
|
|
434
|
+
all_after_pass: false # Run all suites after a suite has passed again
|
|
389
435
|
# after failing.
|
|
390
436
|
# default: true
|
|
391
437
|
```
|
|
@@ -404,19 +450,19 @@ Guard::Jasmine can generate an RSpec like specdoc in the console after running t
|
|
|
404
450
|
be shown in the console:
|
|
405
451
|
|
|
406
452
|
```ruby
|
|
407
|
-
:
|
|
453
|
+
specdoc: :always # Specdoc output options,
|
|
408
454
|
# either :always, :never or :failure
|
|
409
455
|
# default: :failure
|
|
410
456
|
|
|
411
|
-
:
|
|
457
|
+
focus: false # Specdoc focus to hide successful specs when
|
|
412
458
|
# at least one spec fails.
|
|
413
459
|
# default: true
|
|
414
460
|
|
|
415
|
-
:
|
|
461
|
+
console: :always # Console.log output options,
|
|
416
462
|
# either :always, :never or :failure
|
|
417
463
|
# default: :failure
|
|
418
464
|
|
|
419
|
-
:
|
|
465
|
+
errors: :always # Error output options,
|
|
420
466
|
# either :always, :never or :failure
|
|
421
467
|
# default: :failure
|
|
422
468
|
```
|
|
@@ -431,6 +477,17 @@ The `:errors` option is partially working when using at least PhantomJS version
|
|
|
431
477
|
[Issue #166](http://code.google.com/p/phantomjs/issues/detail?id=166) for the actual status of retreiving the JavaScript
|
|
432
478
|
stack trace.
|
|
433
479
|
|
|
480
|
+
### Overwrite options when running all specs
|
|
481
|
+
|
|
482
|
+
You may want to have different options when the spec runner runs all specs. You can specify the `:run_all` option
|
|
483
|
+
as a Hash that contains any valid runner option and will overwrite the general options.
|
|
484
|
+
|
|
485
|
+
```ruby
|
|
486
|
+
run_all: { specdoc: :never } # Run all options,
|
|
487
|
+
# Takes any valid option
|
|
488
|
+
# default: {}
|
|
489
|
+
```
|
|
490
|
+
|
|
434
491
|
#### Console logs
|
|
435
492
|
|
|
436
493
|
The `:console` options adds captured console logs from the spec runner and adds them to the specdoc. Guard:Jasmine
|
|
@@ -458,18 +515,117 @@ You can further customize the log output by implement one of these methods:
|
|
|
458
515
|
In addition, the console can log jQuery collections and outputs the HTML representation of the element by using the
|
|
459
516
|
jQuery `html()` method.
|
|
460
517
|
|
|
518
|
+
### Coverage options
|
|
519
|
+
|
|
520
|
+
Guard::Jasmine supports coverage reports generated by [Istanbul](https://github.com/gotwarlost/istanbul). You need to
|
|
521
|
+
have `istanbul` in your path in order to make this feature work. You can install it with NPM
|
|
522
|
+
|
|
523
|
+
```ruby
|
|
524
|
+
$ npm install -g istanbul
|
|
525
|
+
```
|
|
526
|
+
|
|
527
|
+
You also need to explicit enable the coverage support in the options:
|
|
528
|
+
|
|
529
|
+
```ruby
|
|
530
|
+
coverage: true # Enable/disable JavaScript coverage support
|
|
531
|
+
# default: false
|
|
532
|
+
```
|
|
533
|
+
|
|
534
|
+
### Instrumentation
|
|
535
|
+
|
|
536
|
+
Istanbul needs to instrument the implementation files so that the execution path can be detected. Guard::Jasmine comes
|
|
537
|
+
with a tilt template that generates instrumented implementation files when using in the asset pipeline. If you do not
|
|
538
|
+
use asset pipeline, than you need to instrument your files on your own, either manually (basic example: `istanbul instrument --output instrumented_scripts scripts`) or by using something like
|
|
539
|
+
[Guard::Process](https://github.com/socialreferral/guard-process). You can get more information about the
|
|
540
|
+
instrumentation with `istanbul help instrument`. You'll also need to update your `:spec_dir` or `jasmine.yml/src_dir` settings to point Guard::Jasmine to these instrumented source files.
|
|
541
|
+
|
|
542
|
+
**Important**: You need to clear the asset cache when you change this setting, so that already compiled assets will be
|
|
543
|
+
recompiled. Just use the Sprockets supplied Rake task:
|
|
544
|
+
|
|
545
|
+
```ruby
|
|
546
|
+
$ rake assets:clean
|
|
547
|
+
```
|
|
548
|
+
|
|
549
|
+
#### Check coverage
|
|
550
|
+
|
|
551
|
+
By default Guard::Jasmine just outputs the coverage when enable without any effect on the spec run result. You can
|
|
552
|
+
make Guard::Jasmine fail the spec run when a given threshold is not met. You can set the following thresholds:
|
|
553
|
+
|
|
554
|
+
```ruby
|
|
555
|
+
statements_threshold: 95 # Statements coverage threshold
|
|
556
|
+
# default: 0
|
|
557
|
+
|
|
558
|
+
functions_threshold: 85 # Functions coverage threshold
|
|
559
|
+
# default: 0
|
|
560
|
+
|
|
561
|
+
branches_threshold: -10 # Branches coverage threshold
|
|
562
|
+
# default: 0
|
|
563
|
+
|
|
564
|
+
lines_threshold: -15 # Lines coverage threshold
|
|
565
|
+
# default: 0
|
|
566
|
+
```
|
|
567
|
+
|
|
568
|
+
A positive threshold is taken to be the minimum percentage required, a negative threshold represents the maximum number
|
|
569
|
+
of uncovered entities allowed.
|
|
570
|
+
|
|
571
|
+
#### Coverage report
|
|
572
|
+
|
|
573
|
+
Guard::Jasmine always shows the Istanbul text report after a spec run that contains the coverage results per file. You
|
|
574
|
+
can also enable two more reports:
|
|
575
|
+
|
|
576
|
+
```ruby
|
|
577
|
+
coverage_html: true # Enable Istanbul HTML coverage report
|
|
578
|
+
# default: false
|
|
579
|
+
|
|
580
|
+
coverage_html_dir: './coverage' # Directory to write Istanbul HTML coverage report to
|
|
581
|
+
# default: './coverage'
|
|
582
|
+
|
|
583
|
+
coverage_summary: true # Enable Istanbul summary coverage report
|
|
584
|
+
# default: false
|
|
585
|
+
|
|
586
|
+
ignore_instrumentation: 'vendor' # Ignore files matching this regex when instrumenting
|
|
587
|
+
# default: ''
|
|
588
|
+
```
|
|
589
|
+
|
|
590
|
+
The `:coverage_summary` options disables the detailed file based coverage report by a small summary coverage report.
|
|
591
|
+
|
|
592
|
+
Both of these results are more useful if they are run against the coverage data from a full spec run, so it's strongly
|
|
593
|
+
advised to enable the `:all_on_start` option.
|
|
594
|
+
|
|
595
|
+
With Jasmine in the asset pipeline all instrumented implementation files are available in the runtime and when you
|
|
596
|
+
execute a partial spec run it reports a lower coverage for the excluded files, since their associated specs aren't run.
|
|
597
|
+
Guard::Jasmine tries to work around this by merge only the coverage data for the changed files (Istanbul knows the file
|
|
598
|
+
name in opposite to Jasmine).
|
|
599
|
+
|
|
600
|
+
#### Jenkins CI integration
|
|
601
|
+
|
|
602
|
+
You can use the Cobertura format to bring coverage support to Jenkins CI, even that Guard::Jasmine has no built in
|
|
603
|
+
support for it. The trick is to post-process the coverage data with istanbul after the spec run:
|
|
604
|
+
|
|
605
|
+
```ruby
|
|
606
|
+
desc "Run all JavaScript specs with Istanbul"
|
|
607
|
+
task :jscov => :environment do
|
|
608
|
+
# Run Jasmine tests with code coverage on and generate Jenkins-compatible Jasmine code coverage report file.
|
|
609
|
+
# Must run assets:clean first to force re-compilation.
|
|
610
|
+
# Make sure to fail this task if there are unit test failures.
|
|
611
|
+
# For some reason does not work if run as separate exec's, so combine into one.
|
|
612
|
+
exec('rake assets:clean; guard-jasmine --coverage --coverage-html --coverage-summary; \
|
|
613
|
+
code=$?; if [ $code != "0" ]; then exit $code; fi; istanbul report cobertura')
|
|
614
|
+
end
|
|
615
|
+
```
|
|
616
|
+
|
|
461
617
|
### System notifications options
|
|
462
618
|
|
|
463
|
-
These options affects what system notifications
|
|
619
|
+
These options affects what system notifications are shown after a spec run:
|
|
464
620
|
|
|
465
621
|
```ruby
|
|
466
|
-
:
|
|
622
|
+
notifications: false # Show success and error notifications.
|
|
467
623
|
# default: true
|
|
468
624
|
|
|
469
|
-
:
|
|
625
|
+
hide_success: true # Disable successful spec run notification.
|
|
470
626
|
# default: false
|
|
471
627
|
|
|
472
|
-
:
|
|
628
|
+
max_error_notify: 5 # Maximum error notifications to show.
|
|
473
629
|
# default: 3
|
|
474
630
|
```
|
|
475
631
|
|
|
@@ -506,27 +662,47 @@ Usage:
|
|
|
506
662
|
guard-jasmine spec
|
|
507
663
|
|
|
508
664
|
Options:
|
|
509
|
-
-s, [--server=SERVER]
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
-p, [--port=N]
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
665
|
+
-s, [--server=SERVER] # Server to start, either `auto`, `webrick`, `mongrel`, `thin`, `puma`
|
|
666
|
+
# `unicorn`, `jasmine_gem` or `none`
|
|
667
|
+
# Default: auto
|
|
668
|
+
-p, [--port=N] # Server port to use
|
|
669
|
+
# Default: Random free port
|
|
670
|
+
[--verbose] # Show the server output in the console
|
|
671
|
+
-e, [--server-env=SERVER_ENV] # The server environment to use, for example `development`, `test` etc.
|
|
672
|
+
# Default: test
|
|
673
|
+
[--server-timeout=N] # The number of seconds to wait for the Jasmine spec server
|
|
674
|
+
# Default: 15
|
|
675
|
+
-b, [--bin=BIN] # The location of the PhantomJS binary
|
|
676
|
+
-d, [--spec-dir=SPEC_DIR] # The directory with the Jasmine specs
|
|
677
|
+
# Default: spec/javascripts
|
|
678
|
+
-l, [--line-number=N] # The line which identifies the spec to be run
|
|
679
|
+
-u, [--url=URL] # The url of the Jasmine test runner_options
|
|
680
|
+
# Default: nil
|
|
681
|
+
-t, [--timeout=N] # The maximum time in seconds to wait for the spec
|
|
682
|
+
# runner to finish
|
|
683
|
+
# Default: 10
|
|
684
|
+
[--console=CONSOLE] # Whether to show console.log statements in the spec runner,
|
|
685
|
+
# either `always`, `never` or `failure`
|
|
686
|
+
# Default: failure
|
|
687
|
+
[--errors=ERRORS] # Whether to show errors in the spec runner,
|
|
688
|
+
# either `always`, `never` or `failure`
|
|
689
|
+
# Default: failure
|
|
690
|
+
[--focus] # Specdoc focus to hide successful tests when at least one test fails
|
|
691
|
+
# Default: true
|
|
692
|
+
[--specdoc=SPECDOC] # Whether to show successes in the spec runner, either `always`, `never` or `failure`
|
|
693
|
+
# Default: always
|
|
694
|
+
[--coverage] # Whether to enable the coverage support or not
|
|
695
|
+
[--coverage-html] # Whether to generate html coverage report. Implies --coverage
|
|
696
|
+
[--coverage-html-dir=REPORT_DIR] # Where to save html coverage reports. Defaults to ./coverage. Implies --coverage-html
|
|
697
|
+
[--coverage-summary] # Whether to generate html coverage summary. Implies --coverage
|
|
698
|
+
[--statements-threshold=N] # Statements coverage threshold
|
|
699
|
+
# Default: 0
|
|
700
|
+
[--functions-threshold=N] # Functions coverage threshold
|
|
701
|
+
# Default: 0
|
|
702
|
+
[--branches-threshold=N] # Branches coverage threshold
|
|
703
|
+
# Default: 0
|
|
704
|
+
[--lines-threshold=N] # Lines coverage threshold
|
|
705
|
+
# Default: 0
|
|
530
706
|
Run the Jasmine spec runner
|
|
531
707
|
```
|
|
532
708
|
|
|
@@ -579,14 +755,13 @@ With the given `guard-jasmine` script you're able to configure [Travis CI](http:
|
|
|
579
755
|
Simply use the `script` setting in your `.travis.yml`:
|
|
580
756
|
|
|
581
757
|
```yaml
|
|
582
|
-
script: 'bundle exec guard-jasmine'
|
|
758
|
+
script: 'bundle exec guard-jasmine --server-timeout=60'
|
|
583
759
|
```
|
|
584
760
|
|
|
585
|
-
You can also run your Guard::Jasmine specs after your specs that are ran with `rake` by using
|
|
761
|
+
You can also run your Guard::Jasmine specs after your specs that are ran with `rake` by using `&&`:
|
|
586
762
|
|
|
587
763
|
```yaml
|
|
588
|
-
script: 'rake spec'
|
|
589
|
-
after_script: 'bundle exec guard-jasmine'
|
|
764
|
+
script: 'rake spec && bundle exec guard-jasmine'
|
|
590
765
|
```
|
|
591
766
|
|
|
592
767
|
When using a PhantomJS version prior to 1.5, you need to start `xvfb` before running the specs:
|
|
@@ -597,6 +772,9 @@ before_script:
|
|
|
597
772
|
- "sh -e /etc/init.d/xvfb start"
|
|
598
773
|
```
|
|
599
774
|
|
|
775
|
+
**Tip**: It's highly recommended the have a server timeout of at least 60 seconds, since the performance of the Travis VMs seems to
|
|
776
|
+
vary quite a bit; sometimes the Jasmine server starts in 5 seconds, sometimes it takes as long as 50 seconds.
|
|
777
|
+
|
|
600
778
|
## How to test a Rails engine with Jasmine Gem
|
|
601
779
|
|
|
602
780
|
When building an engine, your code lives at the root but the dummy Rails app is in another folder (like `test/dummy` or `spec/dummy`).
|
|
@@ -621,17 +799,9 @@ Given your configuration, you could also need to set:
|
|
|
621
799
|
There are many ways to get your Jasmine specs run within a headless environment. If Guard::Jasmine isn't for you,
|
|
622
800
|
I recommend to check out these other brilliant Jasmine runners:
|
|
623
801
|
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
* [
|
|
627
|
-
* [guard-jasmine-node][] automatically & intelligently executes Jasmine Node.js specs when files are modified.
|
|
628
|
-
* [guard-jessie][] allows to automatically run you Jasmine specs under Node.js using Jessie runner.
|
|
629
|
-
|
|
630
|
-
### Standalone
|
|
631
|
-
|
|
632
|
-
* [Evergreen][], runs CoffeeScript specs headless, but has no continuous testing support.
|
|
633
|
-
* [Jezebel][] a Node.js REPL and continuous test runner for [Jessie][], a Node runner for Jasmine, but has no full
|
|
634
|
-
featured browser environment.
|
|
802
|
+
* [guard-konacha][], Automatically run [konacha][] tests through Guard.
|
|
803
|
+
* [guard-teabag][], Guard-Teabag: Run Javascript tests with Guard and all the features of [Teabag][]
|
|
804
|
+
* [Karma][] spectacular Test Runner for JavaScript.
|
|
635
805
|
|
|
636
806
|
## How to file an issue
|
|
637
807
|
|
|
@@ -665,6 +835,16 @@ Pull requests are very welcome! Please try to follow these simple rules if appli
|
|
|
665
835
|
For questions please join us in our [Google group](http://groups.google.com/group/guard-dev) or on
|
|
666
836
|
`#guard` (irc.freenode.net).
|
|
667
837
|
|
|
838
|
+
### Open Commit Bit
|
|
839
|
+
|
|
840
|
+
Guard has an open commit bit policy: Anyone with an accepted pull request gets added as a repository collaborator.
|
|
841
|
+
Please try to follow these simple rules:
|
|
842
|
+
|
|
843
|
+
* Commit directly onto the master branch only for typos, improvements to the readme and documentation (please add
|
|
844
|
+
`[ci skip]` to the commit message).
|
|
845
|
+
* Create a feature branch and open a pull-request early for any new features to get feedback.
|
|
846
|
+
* Make sure you adhere to the general pull request rules above.
|
|
847
|
+
|
|
668
848
|
### The guard-jasmine-debug executable
|
|
669
849
|
|
|
670
850
|
This Guard comes with a small executable `guard-jasmine-debug` that can be used to run the Jasmine test runner on PhantomJS
|
|
@@ -676,7 +856,7 @@ $ guard-jasmine-debug
|
|
|
676
856
|
```
|
|
677
857
|
|
|
678
858
|
The only argument that the script takes is the URL to the Jasmine runner, which defaults to
|
|
679
|
-
`http://127.0.0.1:3000/
|
|
859
|
+
`http://127.0.0.1:3000/jasmine`. So you can for example just run a subset of the specs by changing the URL:
|
|
680
860
|
|
|
681
861
|
```bash
|
|
682
862
|
$ guard-jasmine-debug http://127.0.0.1:3000/Jasmine?spec=YourSpec
|
|
@@ -684,7 +864,7 @@ $ guard-jasmine-debug http://127.0.0.1:3000/Jasmine?spec=YourSpec
|
|
|
684
864
|
|
|
685
865
|
## Author
|
|
686
866
|
|
|
687
|
-
Developed by Michael Kessler, sponsored by [
|
|
867
|
+
Developed by Michael Kessler, sponsored by [FlinkFinger](http://www.flinkfinger.com).
|
|
688
868
|
|
|
689
869
|
If you like Guard::Jasmine, you can watch the repository at [GitHub](https://github.com/netzpirat/guard-jasmine) and
|
|
690
870
|
follow [@netzpirat](https://twitter.com/#!/netzpirat) on Twitter for project updates.
|
|
@@ -692,7 +872,7 @@ follow [@netzpirat](https://twitter.com/#!/netzpirat) on Twitter for project upd
|
|
|
692
872
|
## Contributors
|
|
693
873
|
|
|
694
874
|
See the [CHANGELOG](https://github.com/netzpirat/guard-jasmine/blob/master/CHANGELOG.md) and the GitHub list of
|
|
695
|
-
[contributors](https://github.com/netzpirat/
|
|
875
|
+
[contributors](https://github.com/netzpirat/guard-jasmine/contributors).
|
|
696
876
|
|
|
697
877
|
## Acknowledgment
|
|
698
878
|
|
|
@@ -709,7 +889,7 @@ for it!
|
|
|
709
889
|
|
|
710
890
|
(The MIT License)
|
|
711
891
|
|
|
712
|
-
Copyright (c) 2011-
|
|
892
|
+
Copyright (c) 2011-2013 Michael Kessler
|
|
713
893
|
|
|
714
894
|
Permission is hereby granted, free of charge, to any person obtaining
|
|
715
895
|
a copy of this software and associated documentation files (the
|
|
@@ -739,6 +919,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
739
919
|
[PhantomJS build instructions]: http://code.google.com/p/phantomjs/wiki/BuildInstructions
|
|
740
920
|
[Brad Phelan]: http://twitter.com/#!/bradgonesurfing
|
|
741
921
|
[Jasminerice]: https://github.com/bradphelan/jasminerice
|
|
922
|
+
[jasmine-rails]: https://github.com/searls/jasmine-rails
|
|
742
923
|
[Pivotal Labs]: http://pivotallabs.com/
|
|
743
924
|
[Jasmine]: http://pivotal.github.com/jasmine/
|
|
744
925
|
[the Jasmine Gem]: https://github.com/pivotal/jasmine-gem
|
|
@@ -746,14 +927,12 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
746
927
|
[CoffeeScript]: http://jashkenas.github.com/coffee-script/
|
|
747
928
|
[Rails 3.1 asset pipeline]: http://guides.rubyonrails.org/asset_pipeline.html
|
|
748
929
|
[Homebrew]: http://mxcl.github.com/homebrew/
|
|
749
|
-
[Jezebel]: https://github.com/benrady/jezebel
|
|
750
|
-
[Jessie]: https://github.com/futuresimple/jessie
|
|
751
|
-
[guard-jasmine-headless-webkit]: https://github.com/johnbintz/guard-jasmine-headless-webkit
|
|
752
|
-
[jasmine-headless-webkit]: https://github.com/johnbintz/jasmine-headless-webkit/
|
|
753
|
-
[Evergreen]: https://github.com/jnicklas/evergreen
|
|
754
930
|
[PhantomJS script]: https://github.com/netzpirat/guard-jasmine/blob/master/lib/guard/jasmine/phantomjs/guard-jasmine.coffee
|
|
755
931
|
[Guard::CoffeeScript]: https://github.com/guard/guard-coffeescript
|
|
756
932
|
[Sinon.JS]: http://sinonjs.org
|
|
757
|
-
[guard-jasmine-node]: https://github.com/guard/guard-jasmine-node
|
|
758
|
-
[guard-jessie]: https://github.com/guard/guard-jessie
|
|
759
933
|
[Rails asset pipeline]: http://guides.rubyonrails.org/asset_pipeline.html
|
|
934
|
+
[guard-konacha]: https://github.com/alexgb/guard-konacha
|
|
935
|
+
[konacha]: https://github.com/jfirebaugh/konacha
|
|
936
|
+
[Karma]: https://github.com/karma-runner/karma
|
|
937
|
+
[guard-teabag]: https://github.com/modeset/guard-teabag
|
|
938
|
+
[Teabag]: https://github.com/modeset/teabag
|
data/bin/guard-jasmine-debug
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
|
-
script = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'guard', 'jasmine', 'phantomjs', 'guard-jasmine.
|
|
2
|
+
script = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'guard', 'jasmine', 'phantomjs', 'guard-jasmine.js'))
|
|
3
3
|
puts `phantomjs #{ script } #{ ARGV[0] } #{ ARGV[1] }`
|