guard-jasmine 1.14.0 → 1.15.0
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/README.md +35 -35
- data/lib/guard/jasmine.rb +33 -30
- data/lib/guard/jasmine/cli.rb +73 -73
- data/lib/guard/jasmine/phantomjs/guard-jasmine.coffee +2 -2
- data/lib/guard/jasmine/phantomjs/guard-jasmine.js +3 -4
- data/lib/guard/jasmine/phantomjs/lib/result.js +20 -0
- data/lib/guard/jasmine/phantomjs/src/result.coffee +16 -1
- data/lib/guard/jasmine/runner.rb +13 -13
- data/lib/guard/jasmine/server.rb +23 -24
- data/lib/guard/jasmine/version.rb +1 -1
- metadata +17 -29
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 35f755fd7988fb41009cc1377514706c7d2d8700
|
4
|
+
data.tar.gz: 2d67d8daefc22be085e6d883778766a8e10e1795
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a563757370395d7a09befdea85915bebcbff02c4fda5d0244894ea0b86b29a2f0dc85c74e3d558b7a1c83d246a4d45040540f7f1dfa43cd5212c103a5beddd5e
|
7
|
+
data.tar.gz: 9433f80970d0d1a4b6347c15e0b580658ed2bd4939db6bb157ef538c62eff82ab125294807852c7938e5221a1702db8250e11380a4c373261a6f48a36875b868
|
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.2, 1.9.3, 2.0.0 and the latest version of JRuby.
|
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).
|
@@ -170,7 +170,7 @@ Now you can access `/jasmine-stories` when you start your Rails server normally.
|
|
170
170
|
accordingly:
|
171
171
|
|
172
172
|
```ruby
|
173
|
-
guard :jasmine, :
|
173
|
+
guard :jasmine, port: 8888, jasmine_url: 'http://127.0.0.1:8888/jasmine-stories' do
|
174
174
|
...
|
175
175
|
end
|
176
176
|
```
|
@@ -234,8 +234,8 @@ It is also possible to use CoffeeScript in this setup, by using [Guard::CoffeeSc
|
|
234
234
|
specs. Just add something like this *before* Guard::Jasmine:
|
235
235
|
|
236
236
|
```ruby
|
237
|
-
guard 'coffeescript', :
|
238
|
-
guard 'coffeescript', :
|
237
|
+
guard 'coffeescript', input: 'app/coffeescripts', output: 'public/javascripts'
|
238
|
+
guard 'coffeescript', input: 'spec/coffeescripts', output: 'spec/javascripts'
|
239
239
|
```
|
240
240
|
|
241
241
|
## Ruby projects
|
@@ -279,7 +279,7 @@ require 'jquery-rails'
|
|
279
279
|
|
280
280
|
class JasmineTest < Rails::Application
|
281
281
|
routes.append do
|
282
|
-
mount Jasminerice::Engine
|
282
|
+
mount Jasminerice::Engine: '/jasmine'
|
283
283
|
end
|
284
284
|
|
285
285
|
config.cache_classes = true
|
@@ -329,7 +329,7 @@ There are many options that can customize Guard::Jasmine to your needs. Options
|
|
329
329
|
defining the Guard in your `Guardfile`:
|
330
330
|
|
331
331
|
```ruby
|
332
|
-
guard 'jasmine', :
|
332
|
+
guard 'jasmine', all_on_start: false, specdoc: :always do
|
333
333
|
...
|
334
334
|
end
|
335
335
|
```
|
@@ -339,27 +339,27 @@ end
|
|
339
339
|
The server options configures the server environment that is needed to run Guard::Jasmine:
|
340
340
|
|
341
341
|
```ruby
|
342
|
-
|
342
|
+
server: :jasmine_gem # Jasmine server to use, either :auto, :none,
|
343
343
|
# :webrick, :mongrel, :thin, :unicorn, :jasmine_gem, :puma
|
344
344
|
# default: :auto
|
345
345
|
|
346
|
-
|
346
|
+
server_env: :test # Jasmine server Rails environment to set,
|
347
347
|
# e.g. :development or :test
|
348
348
|
# default: RAILS_ENV is exists, otherwise :development
|
349
349
|
|
350
|
-
:
|
350
|
+
server_timeout: 30 # The number of seconds to wait for the Jasmine spec server
|
351
351
|
# default: 15
|
352
352
|
|
353
|
-
:
|
353
|
+
port: 8888 # Jasmine server port to use.
|
354
354
|
# default: a random, free server port
|
355
355
|
|
356
|
-
:
|
356
|
+
phantomjs_bin: '~/bin/phantomjs' # Path to phantomjs.
|
357
357
|
# default: auto-detect 'phantomjs'
|
358
358
|
|
359
|
-
:
|
359
|
+
timeout: 20 # The time in seconds to wait for the spec runner to finish.
|
360
360
|
# default: 10
|
361
361
|
|
362
|
-
:
|
362
|
+
rackup_config: 'spec/dummy/config.ru' # Path to rackup config file (i.e. for webrick, mongrel, thin, unicorn, puma).
|
363
363
|
# default: ./config.ru
|
364
364
|
# This option is useful when using guard-jasmine in a mountable engine
|
365
365
|
# and the config.ru is within the dummy app
|
@@ -369,7 +369,7 @@ If you're setting the `:server` option to `:none` or need to access your specs o
|
|
369
369
|
supply the Jasmine runner url manually:
|
370
370
|
|
371
371
|
```ruby
|
372
|
-
:
|
372
|
+
jasmine_url: 'http://192.168.1.5:1234/jasmine' # URL where Jasmine is served.
|
373
373
|
# default: nil
|
374
374
|
```
|
375
375
|
You may want to have also a fixed port instead of the random generated one.
|
@@ -382,7 +382,7 @@ instead of a ridiculous high line number in a single, very large JavaScript.
|
|
382
382
|
|
383
383
|
If you supply an unknown server name as the `:server` option, then Guard::Jasmine will execute
|
384
384
|
a `rake` task with the given server name as task in a child process. For example, if you configure
|
385
|
-
|
385
|
+
`server: 'start_my_server'`, then the command `rake start_my_server` will be executed and
|
386
386
|
you have to make sure the server starts on the port that you can get from the `JASMINE_PORT`
|
387
387
|
environment variable.
|
388
388
|
|
@@ -391,19 +391,19 @@ environment variable.
|
|
391
391
|
The spec runner options configures the behavior driven development (or BDD) cycle:
|
392
392
|
|
393
393
|
```ruby
|
394
|
-
:
|
394
|
+
spec_dir: 'app/spec' # Directory with the Jasmine specs.
|
395
395
|
# default: 'spec/javascripts'
|
396
396
|
|
397
|
-
:
|
397
|
+
clean: false # Clean the spec list by only keep Jasmine specs within the project.
|
398
398
|
# default: true
|
399
399
|
|
400
|
-
:
|
400
|
+
all_on_start: false # Run all suites on start.
|
401
401
|
# default: true
|
402
402
|
|
403
|
-
:
|
403
|
+
keep_failed: false # Keep failed suites and add them to the next run again.
|
404
404
|
# default: true
|
405
405
|
|
406
|
-
:
|
406
|
+
all_after_pass: false # Run all suites after a suite has passed again
|
407
407
|
# after failing.
|
408
408
|
# default: true
|
409
409
|
```
|
@@ -422,19 +422,19 @@ Guard::Jasmine can generate an RSpec like specdoc in the console after running t
|
|
422
422
|
be shown in the console:
|
423
423
|
|
424
424
|
```ruby
|
425
|
-
:
|
425
|
+
specdoc: :always # Specdoc output options,
|
426
426
|
# either :always, :never or :failure
|
427
427
|
# default: :failure
|
428
428
|
|
429
|
-
:
|
429
|
+
focus: false # Specdoc focus to hide successful specs when
|
430
430
|
# at least one spec fails.
|
431
431
|
# default: true
|
432
432
|
|
433
|
-
:
|
433
|
+
console: :always # Console.log output options,
|
434
434
|
# either :always, :never or :failure
|
435
435
|
# default: :failure
|
436
436
|
|
437
|
-
:
|
437
|
+
errors: :always # Error output options,
|
438
438
|
# either :always, :never or :failure
|
439
439
|
# default: :failure
|
440
440
|
```
|
@@ -455,7 +455,7 @@ You may want to have different options when the spec runner runs all specs. You
|
|
455
455
|
as a Hash that contains any valid runner option and will overwrite the general options.
|
456
456
|
|
457
457
|
```ruby
|
458
|
-
:
|
458
|
+
run_all: { specdoc: :never } # Run all options,
|
459
459
|
# Takes any valid option
|
460
460
|
# default: {}
|
461
461
|
```
|
@@ -499,7 +499,7 @@ $ npm install -g istanbul
|
|
499
499
|
You also need to explicit enable the coverage support in the options:
|
500
500
|
|
501
501
|
```ruby
|
502
|
-
:
|
502
|
+
coverage: true # Enable/disable JavaScript coverage support
|
503
503
|
# default: false
|
504
504
|
```
|
505
505
|
|
@@ -524,16 +524,16 @@ By default Guard::Jasmine just outputs the coverage when enable without any effe
|
|
524
524
|
make Guard::Jasmine fail the spec run when a given threshold is not met. You can set the following thresholds:
|
525
525
|
|
526
526
|
```ruby
|
527
|
-
:
|
527
|
+
statements_threshold: 95 # Statements coverage threshold
|
528
528
|
# default: 0
|
529
529
|
|
530
|
-
:
|
530
|
+
functions_threshold: 85 # Functions coverage threshold
|
531
531
|
# default: 0
|
532
532
|
|
533
|
-
:
|
533
|
+
branches_threshold: -10 # Branches coverage threshold
|
534
534
|
# default: 0
|
535
535
|
|
536
|
-
:
|
536
|
+
lines_threshold: -15 # Lines coverage threshold
|
537
537
|
# default: 0
|
538
538
|
```
|
539
539
|
|
@@ -546,10 +546,10 @@ Guard::Jasmine always shows the Istanbul text report after a spec run that conta
|
|
546
546
|
can also enable two more reports:
|
547
547
|
|
548
548
|
```ruby
|
549
|
-
:
|
549
|
+
coverage_html: true # Enable Istanbul HTML coverage report
|
550
550
|
# default: false
|
551
551
|
|
552
|
-
:
|
552
|
+
coverage_summary: true # Enable Istanbul summary coverage report
|
553
553
|
# default: false
|
554
554
|
```
|
555
555
|
|
@@ -568,13 +568,13 @@ name in opposite to Jasmine).
|
|
568
568
|
These options affects what system notifications are shown after a spec run:
|
569
569
|
|
570
570
|
```ruby
|
571
|
-
:
|
571
|
+
notifications: false # Show success and error notifications.
|
572
572
|
# default: true
|
573
573
|
|
574
|
-
:
|
574
|
+
hide_success: true # Disable successful spec run notification.
|
575
575
|
# default: false
|
576
576
|
|
577
|
-
:
|
577
|
+
max_error_notify: 5 # Maximum error notifications to show.
|
578
578
|
# default: 3
|
579
579
|
```
|
580
580
|
|
data/lib/guard/jasmine.rb
CHANGED
@@ -22,32 +22,32 @@ module Guard
|
|
22
22
|
attr_accessor :last_run_failed, :last_failed_paths, :run_all_options
|
23
23
|
|
24
24
|
DEFAULT_OPTIONS = {
|
25
|
-
:
|
26
|
-
:
|
27
|
-
:
|
28
|
-
:
|
29
|
-
:
|
30
|
-
:
|
31
|
-
:
|
32
|
-
:
|
33
|
-
:
|
34
|
-
:
|
35
|
-
:
|
36
|
-
:
|
37
|
-
:
|
38
|
-
:
|
39
|
-
:
|
40
|
-
:
|
41
|
-
:
|
42
|
-
:
|
43
|
-
:
|
44
|
-
:
|
45
|
-
:
|
46
|
-
:
|
47
|
-
:
|
48
|
-
:
|
49
|
-
:
|
50
|
-
:
|
25
|
+
server: :auto,
|
26
|
+
server_env: ENV['RAILS_ENV'] || 'development',
|
27
|
+
server_timeout: 60,
|
28
|
+
port: nil,
|
29
|
+
rackup_config: nil,
|
30
|
+
jasmine_url: nil,
|
31
|
+
timeout: 60,
|
32
|
+
spec_dir: nil,
|
33
|
+
notification: true,
|
34
|
+
hide_success: false,
|
35
|
+
all_on_start: true,
|
36
|
+
keep_failed: true,
|
37
|
+
clean: true,
|
38
|
+
all_after_pass: true,
|
39
|
+
max_error_notify: 3,
|
40
|
+
specdoc: :failure,
|
41
|
+
console: :failure,
|
42
|
+
errors: :failure,
|
43
|
+
focus: true,
|
44
|
+
coverage: false,
|
45
|
+
coverage_html: false,
|
46
|
+
coverage_summary: false,
|
47
|
+
statements_threshold: 0,
|
48
|
+
functions_threshold: 0,
|
49
|
+
branches_threshold: 0,
|
50
|
+
lines_threshold: 0
|
51
51
|
}
|
52
52
|
|
53
53
|
# Initialize Guard::Jasmine.
|
@@ -84,11 +84,14 @@ module Guard
|
|
84
84
|
# @option options [Hash] :run_all options overwrite options when run all specs
|
85
85
|
#
|
86
86
|
def initialize(watchers = [], options = { })
|
87
|
-
options[:port] ||= Jasmine.find_free_server_port
|
88
|
-
options[:jasmine_url] = "http://localhost:#{ options[:port] }#{ options[:server] == :jasmine_gem ? '/' : '/jasmine' }" unless options[:jasmine_url]
|
89
87
|
options = DEFAULT_OPTIONS.merge(options)
|
90
|
-
|
91
|
-
options[:
|
88
|
+
|
89
|
+
options[:spec_dir] ||= File.exists?(File.join('spec', 'javascripts')) ? File.join('spec', 'javascripts') : 'spec'
|
90
|
+
options[:port] ||= Jasmine.find_free_server_port
|
91
|
+
options[:server] ||= :auto
|
92
|
+
options[:server] = ::Guard::Jasmine::Server.detect_server(options[:spec_dir]) if options[:server] == :auto
|
93
|
+
options[:jasmine_url] = "http://localhost:#{ options[:port] }#{ options[:server] == :jasmine_gem ? '/' : '/jasmine' }" unless options[:jasmine_url]
|
94
|
+
options[:specdoc] = :failure if ![:always, :never, :failure].include? options[:specdoc]
|
92
95
|
options[:phantomjs_bin] = Jasmine.which('phantomjs') unless options[:phantomjs_bin]
|
93
96
|
|
94
97
|
self.run_all_options = options.delete(:run_all) || { }
|
data/lib/guard/jasmine/cli.rb
CHANGED
@@ -5,6 +5,7 @@ require 'guard/jasmine/runner'
|
|
5
5
|
require 'guard/jasmine/formatter'
|
6
6
|
require 'guard/jasmine/server'
|
7
7
|
require 'guard/jasmine/util'
|
8
|
+
require 'guard/jasmine/server'
|
8
9
|
|
9
10
|
module Guard
|
10
11
|
class Jasmine
|
@@ -23,114 +24,113 @@ module Guard
|
|
23
24
|
desc 'spec', 'Run the Jasmine spec runner_options'
|
24
25
|
|
25
26
|
method_option :server,
|
26
|
-
:
|
27
|
-
:
|
28
|
-
:
|
29
|
-
:
|
27
|
+
type: :string,
|
28
|
+
aliases: '-s',
|
29
|
+
default: 'auto',
|
30
|
+
desc: 'Server to start, either `auto`, `webrick`, `mongrel`, `thin`, `unicorn`, `jasmine_gem` or `none`'
|
30
31
|
|
31
32
|
method_option :port,
|
32
|
-
:
|
33
|
-
:
|
34
|
-
:
|
33
|
+
type: :numeric,
|
34
|
+
aliases: '-p',
|
35
|
+
desc: 'Server port to use'
|
35
36
|
|
36
37
|
method_option :server_env,
|
37
|
-
:
|
38
|
-
:
|
39
|
-
:
|
40
|
-
:
|
38
|
+
type: :string,
|
39
|
+
aliases: '-e',
|
40
|
+
default: ENV['RAILS_ENV'] || 'test',
|
41
|
+
desc: 'The server environment to use, for example `development`, `test` etc.'
|
41
42
|
|
42
43
|
method_option :server_timeout,
|
43
|
-
:
|
44
|
-
:
|
45
|
-
:
|
44
|
+
type: :numeric,
|
45
|
+
default: 60,
|
46
|
+
desc: 'The number of seconds to wait for the Jasmine spec server'
|
46
47
|
|
47
48
|
method_option :verbose,
|
48
|
-
:
|
49
|
-
:
|
50
|
-
:
|
49
|
+
type: :boolean,
|
50
|
+
default: false,
|
51
|
+
desc: 'Show the server output in the console'
|
51
52
|
|
52
53
|
method_option :rackup_config,
|
53
|
-
:
|
54
|
-
:
|
55
|
-
:
|
54
|
+
type: :string,
|
55
|
+
aliases: '-c',
|
56
|
+
desc: 'The rackup config to use (jasminerice only)'
|
56
57
|
|
57
58
|
method_option :bin,
|
58
|
-
:
|
59
|
-
:
|
60
|
-
:
|
59
|
+
type: :string,
|
60
|
+
aliases: '-b',
|
61
|
+
desc: 'The location of the PhantomJS binary'
|
61
62
|
|
62
63
|
method_option :spec_dir,
|
63
|
-
:
|
64
|
-
:
|
65
|
-
:
|
66
|
-
:desc => 'The directory with the Jasmine specs'
|
64
|
+
type: :string,
|
65
|
+
aliases: '-d',
|
66
|
+
desc: 'The directory with the Jasmine specs'
|
67
67
|
|
68
68
|
method_option :url,
|
69
|
-
:
|
70
|
-
:
|
71
|
-
:
|
69
|
+
type: :string,
|
70
|
+
aliases: '-u',
|
71
|
+
desc: 'The url of the Jasmine test runner'
|
72
72
|
|
73
73
|
method_option :timeout,
|
74
|
-
:
|
75
|
-
:
|
76
|
-
:
|
77
|
-
:
|
74
|
+
type: :numeric,
|
75
|
+
aliases: '-t',
|
76
|
+
default: 60,
|
77
|
+
desc: 'The maximum time in seconds to wait for the spec runner to finish'
|
78
78
|
|
79
79
|
method_option :console,
|
80
|
-
:
|
81
|
-
:
|
82
|
-
:
|
80
|
+
type: :string,
|
81
|
+
default: 'failure',
|
82
|
+
desc: 'Whether to show console.log statements in the spec runner, either `always`, `never` or `failure`'
|
83
83
|
|
84
84
|
method_option :errors,
|
85
|
-
:
|
86
|
-
:
|
87
|
-
:
|
85
|
+
type: :string,
|
86
|
+
default: 'failure',
|
87
|
+
desc: 'Whether to show errors in the spec runner, either `always`, `never` or `failure`'
|
88
88
|
|
89
89
|
method_option :focus,
|
90
|
-
:
|
91
|
-
:
|
92
|
-
:
|
93
|
-
:
|
90
|
+
type: :boolean,
|
91
|
+
aliases: '-f',
|
92
|
+
default: true,
|
93
|
+
desc: 'Specdoc focus to hide successful tests when at least one test fails'
|
94
94
|
|
95
95
|
method_option :specdoc,
|
96
|
-
:
|
97
|
-
:
|
98
|
-
:
|
96
|
+
type: :string,
|
97
|
+
default: :always,
|
98
|
+
desc: 'Whether to show successes in the spec runner, either `always`, `never` or `failure`'
|
99
99
|
|
100
100
|
method_option :coverage,
|
101
|
-
:
|
102
|
-
:
|
103
|
-
:
|
101
|
+
type: :boolean,
|
102
|
+
default: false,
|
103
|
+
desc: 'Whether to enable the coverage support or not'
|
104
104
|
|
105
105
|
method_option :coverage_html,
|
106
|
-
:
|
107
|
-
:
|
108
|
-
:
|
106
|
+
type: :boolean,
|
107
|
+
default: false,
|
108
|
+
desc: 'Whether to generate html coverage report. Implies --coverage'
|
109
109
|
|
110
110
|
method_option :coverage_summary,
|
111
|
-
:
|
112
|
-
:
|
113
|
-
:
|
111
|
+
type: :boolean,
|
112
|
+
default: false,
|
113
|
+
desc: 'Whether to generate html coverage summary. Implies --coverage'
|
114
114
|
|
115
115
|
method_option :statements_threshold,
|
116
|
-
:
|
117
|
-
:
|
118
|
-
:
|
116
|
+
type: :numeric,
|
117
|
+
default: 0,
|
118
|
+
desc: 'Statements coverage threshold'
|
119
119
|
|
120
120
|
method_option :functions_threshold,
|
121
|
-
:
|
122
|
-
:
|
123
|
-
:
|
121
|
+
type: :numeric,
|
122
|
+
default: 0,
|
123
|
+
desc: 'Functions coverage threshold'
|
124
124
|
|
125
125
|
method_option :branches_threshold,
|
126
|
-
:
|
127
|
-
:
|
128
|
-
:
|
126
|
+
type: :numeric,
|
127
|
+
default: 0,
|
128
|
+
desc: 'Branches coverage threshold'
|
129
129
|
|
130
130
|
method_option :lines_threshold,
|
131
|
-
:
|
132
|
-
:
|
133
|
-
:
|
131
|
+
type: :numeric,
|
132
|
+
default: 0,
|
133
|
+
desc: 'Lines coverage threshold'
|
134
134
|
|
135
135
|
# Run the Guard::Jasmine::Runner with options from
|
136
136
|
# the command line.
|
@@ -138,19 +138,17 @@ module Guard
|
|
138
138
|
# @param [Array<String>] paths the name of the specs to run
|
139
139
|
#
|
140
140
|
def spec(*paths)
|
141
|
-
|
142
|
-
|
143
|
-
runner_options = { }
|
141
|
+
runner_options = {}
|
144
142
|
runner_options[:port] = options.port || CLI.find_free_server_port
|
143
|
+
runner_options[:spec_dir] = options.spec_dir || (File.exists?(File.join('spec', 'javascripts')) ? File.join('spec', 'javascripts') : 'spec')
|
144
|
+
runner_options[:server] = options.server.to_sym == :auto ? ::Guard::Jasmine::Server.detect_server(runner_options[:spec_dir]) : options.server.to_sym
|
145
145
|
runner_options[:jasmine_url] = options.url || "http://localhost:#{ runner_options[:port] }#{ options.server.to_sym == :jasmine_gem ? '/' : '/jasmine' }"
|
146
146
|
runner_options[:phantomjs_bin] = options.bin || CLI.which('phantomjs')
|
147
147
|
runner_options[:timeout] = options.timeout
|
148
148
|
runner_options[:verbose] = options.verbose
|
149
|
-
runner_options[:server] = options.server.to_sym
|
150
149
|
runner_options[:server_env] = options.server_env
|
151
150
|
runner_options[:server_timeout] = options.server_timeout
|
152
151
|
runner_options[:rackup_config] = options.rackup_config
|
153
|
-
runner_options[:spec_dir] = options.spec_dir
|
154
152
|
runner_options[:console] = [:always, :never, :failure].include?(options.console.to_sym) ? options.console.to_sym : :failure
|
155
153
|
runner_options[:errors] = [:always, :never, :failure].include?(options.errors.to_sym) ? options.errors.to_sym : :failure
|
156
154
|
runner_options[:specdoc] = [:always, :never, :failure].include?(options.specdoc.to_sym) ? options.specdoc.to_sym : :always
|
@@ -166,6 +164,8 @@ module Guard
|
|
166
164
|
runner_options[:hide_success] = true
|
167
165
|
runner_options[:max_error_notify] = 0
|
168
166
|
|
167
|
+
paths = [runner_options[:spec_dir]] if paths.empty?
|
168
|
+
|
169
169
|
if CLI.phantomjs_bin_valid?(runner_options[:phantomjs_bin])
|
170
170
|
catch(:task_has_failed) do
|
171
171
|
::Guard::Jasmine::Server.start(runner_options) unless runner_options[:server] == :none
|
@@ -24,7 +24,7 @@ errors = {}
|
|
24
24
|
# Catch JavaScript errors
|
25
25
|
#
|
26
26
|
page.onError = (msg, trace) ->
|
27
|
-
if currentSpecId
|
27
|
+
if currentSpecId
|
28
28
|
errors[currentSpecId] ||= []
|
29
29
|
errors[currentSpecId].push({ msg: msg, trace: trace })
|
30
30
|
|
@@ -42,7 +42,7 @@ page.onConsoleMessage = (msg, line, source) ->
|
|
42
42
|
logs[currentSpecId] = []
|
43
43
|
|
44
44
|
else
|
45
|
-
logs[currentSpecId].push(msg)
|
45
|
+
logs[currentSpecId].push(msg)
|
46
46
|
|
47
47
|
# Initialize the page before the JavaScript is run.
|
48
48
|
#
|
@@ -1,3 +1,4 @@
|
|
1
|
+
// Generated by CoffeeScript 1.3.3
|
1
2
|
(function() {
|
2
3
|
var currentSpecId, errors, logs, options, page, specsReady, waitFor;
|
3
4
|
|
@@ -21,7 +22,7 @@
|
|
21
22
|
errors = {};
|
22
23
|
|
23
24
|
page.onError = function(msg, trace) {
|
24
|
-
if (currentSpecId
|
25
|
+
if (currentSpecId) {
|
25
26
|
errors[currentSpecId] || (errors[currentSpecId] = []);
|
26
27
|
return errors[currentSpecId].push({
|
27
28
|
msg: msg,
|
@@ -44,9 +45,7 @@
|
|
44
45
|
currentSpecId = Number(RegExp.$1);
|
45
46
|
return logs[currentSpecId] = [];
|
46
47
|
} else {
|
47
|
-
|
48
|
-
return logs[currentSpecId].push(msg);
|
49
|
-
}
|
48
|
+
return logs[currentSpecId].push(msg);
|
50
49
|
}
|
51
50
|
};
|
52
51
|
|
@@ -1,3 +1,4 @@
|
|
1
|
+
// Generated by CoffeeScript 1.3.3
|
1
2
|
(function() {
|
2
3
|
var Result;
|
3
4
|
|
@@ -76,6 +77,24 @@
|
|
76
77
|
return suite;
|
77
78
|
};
|
78
79
|
|
80
|
+
Result.prototype.addGlobalErrors = function(suite) {
|
81
|
+
var b, err, errMsg, globalErrors, noSpecs, noSuites, _i, _len, _ref;
|
82
|
+
noSuites = !suite.suites || suite.suites.length === 0;
|
83
|
+
noSpecs = !suite.specs || suite.specs.length === 0;
|
84
|
+
globalErrors = this.errors[-1] && this.errors[-1].length !== 0;
|
85
|
+
if (noSuites && noSpecs && globalErrors) {
|
86
|
+
err = this.errors[-1][0];
|
87
|
+
errMsg = [err.msg];
|
88
|
+
_ref = err.trace;
|
89
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
90
|
+
b = _ref[_i];
|
91
|
+
errMsg.push("\n " + b.file + ":" + b.line + " " + b["function"]);
|
92
|
+
}
|
93
|
+
suite.error = errMsg.join("");
|
94
|
+
return suite.passed = false;
|
95
|
+
}
|
96
|
+
};
|
97
|
+
|
79
98
|
Result.prototype.cleanResult = function(suite) {
|
80
99
|
var s, spec, _i, _len, _ref;
|
81
100
|
suite.suites = (function() {
|
@@ -106,6 +125,7 @@
|
|
106
125
|
}
|
107
126
|
if (this.options.errors !== 'never') {
|
108
127
|
this.addErrors(this.result);
|
128
|
+
this.addGlobalErrors(this.result);
|
109
129
|
}
|
110
130
|
this.cleanResult(this.result);
|
111
131
|
return this.result;
|
@@ -45,6 +45,19 @@ class Result
|
|
45
45
|
|
46
46
|
suite
|
47
47
|
|
48
|
+
addGlobalError: (suite) ->
|
49
|
+
noSuites = !suite.suites || suite.suites.length == 0
|
50
|
+
noSpecs = !suite.specs || suite.specs.length == 0
|
51
|
+
globalErrors = @errors[-1] && @errors[-1].length != 0
|
52
|
+
|
53
|
+
if noSuites && noSpecs && globalErrors
|
54
|
+
err = @errors[-1][0]
|
55
|
+
errMsg = [ err.msg ]
|
56
|
+
for b in err.trace
|
57
|
+
errMsg.push "\n #{b.file}:#{b.line} #{b.function}"
|
58
|
+
suite.error = errMsg.join("")
|
59
|
+
suite.passed = false
|
60
|
+
|
48
61
|
# Clean unnecessary properties from the result
|
49
62
|
#
|
50
63
|
# @param [Object] suite the suite result
|
@@ -69,7 +82,9 @@ class Result
|
|
69
82
|
#
|
70
83
|
process: ->
|
71
84
|
@addLogs(@result) if @options.console isnt 'never'
|
72
|
-
|
85
|
+
if @options.errors isnt 'never'
|
86
|
+
@addErrors(@result)
|
87
|
+
@addGlobalError(@result)
|
73
88
|
@cleanResult(@result)
|
74
89
|
|
75
90
|
@result
|
data/lib/guard/jasmine/runner.rb
CHANGED
@@ -64,7 +64,7 @@ module Guard
|
|
64
64
|
"Run Jasmine suite#{ paths.size == 1 ? '' : 's' } #{ paths.join(' ') }"
|
65
65
|
end
|
66
66
|
|
67
|
-
Formatter.info(message, :
|
67
|
+
Formatter.info(message, reset: true)
|
68
68
|
end
|
69
69
|
|
70
70
|
# Returns the failed spec file names.
|
@@ -167,7 +167,7 @@ module Guard
|
|
167
167
|
json = json.encode('UTF-8') if json.respond_to?(:encode)
|
168
168
|
|
169
169
|
begin
|
170
|
-
result = MultiJson.decode(json, { :
|
170
|
+
result = MultiJson.decode(json, { max_nesting: false })
|
171
171
|
|
172
172
|
if result['error']
|
173
173
|
notify_runtime_error(result, options)
|
@@ -204,7 +204,7 @@ module Guard
|
|
204
204
|
def notify_runtime_error(result, options)
|
205
205
|
message = "An error occurred: #{ result['error'] }"
|
206
206
|
Formatter.error(message)
|
207
|
-
Formatter.notify(message, :
|
207
|
+
Formatter.notify(message, title: 'Jasmine error', image: :failed, priority: 2) if options[:notification]
|
208
208
|
end
|
209
209
|
|
210
210
|
# Notification about a spec run, success or failure,
|
@@ -231,12 +231,12 @@ module Guard
|
|
231
231
|
if passed
|
232
232
|
report_specdoc(result, passed, options)
|
233
233
|
Formatter.success(message)
|
234
|
-
Formatter.notify(full_message, :
|
234
|
+
Formatter.notify(full_message, title: 'Jasmine suite passed') if options[:notification] && !options[:hide_success]
|
235
235
|
else
|
236
236
|
report_specdoc(result, passed, options)
|
237
237
|
Formatter.error(message)
|
238
238
|
notify_errors(result, options)
|
239
|
-
Formatter.notify(full_message, :
|
239
|
+
Formatter.notify(full_message, title: 'Jasmine suite failed', image: :failed, priority: 2) if options[:notification]
|
240
240
|
end
|
241
241
|
|
242
242
|
Formatter.info("Done.\n")
|
@@ -307,10 +307,10 @@ module Guard
|
|
307
307
|
|
308
308
|
if failed
|
309
309
|
Formatter.error coverage
|
310
|
-
Formatter.notify(coverage, :
|
310
|
+
Formatter.notify(coverage, title: 'Code coverage failed', image: :failed, priority: 2) if options[:notification]
|
311
311
|
else
|
312
312
|
Formatter.success 'Code coverage succeed'
|
313
|
-
Formatter.notify('All code is adequately covered with specs', :
|
313
|
+
Formatter.notify('All code is adequately covered with specs', title: 'Code coverage succeed') if options[:notification] && !options[:hide_success]
|
314
314
|
end
|
315
315
|
end
|
316
316
|
end
|
@@ -523,9 +523,9 @@ module Guard
|
|
523
523
|
if !spec['passed'] && options[:max_error_notify] > index
|
524
524
|
msg = spec['messages'].map { |message| format_message(message, true) }.join(', ')
|
525
525
|
Formatter.notify("#{ spec['description'] }: #{ msg }",
|
526
|
-
:
|
527
|
-
:
|
528
|
-
:
|
526
|
+
title: 'Jasmine spec failed',
|
527
|
+
image: :failed,
|
528
|
+
priority: 2) if options[:notification]
|
529
529
|
end
|
530
530
|
end
|
531
531
|
end
|
@@ -575,17 +575,17 @@ module Guard
|
|
575
575
|
#
|
576
576
|
def update_coverage(coverage, file, options)
|
577
577
|
if file == options[:spec_dir]
|
578
|
-
File.write(coverage_file, MultiJson.encode(coverage, { :
|
578
|
+
File.write(coverage_file, MultiJson.encode(coverage, { max_nesting: false }))
|
579
579
|
else
|
580
580
|
if File.exist?(coverage_file)
|
581
581
|
impl = file.sub('_spec', '').sub(options[:spec_dir], '')
|
582
|
-
coverage = MultiJson.decode(File.read(coverage_file), { :
|
582
|
+
coverage = MultiJson.decode(File.read(coverage_file), { max_nesting: false })
|
583
583
|
|
584
584
|
coverage.each do |coverage_file, data|
|
585
585
|
coverage[coverage_file] = data if coverage_file == impl
|
586
586
|
end
|
587
587
|
|
588
|
-
File.write(coverage_file, MultiJson.encode(coverage, { :
|
588
|
+
File.write(coverage_file, MultiJson.encode(coverage, { max_nesting: false }))
|
589
589
|
else
|
590
590
|
File.write(coverage_file, MultiJson.encode({ }))
|
591
591
|
end
|
data/lib/guard/jasmine/server.rb
CHANGED
@@ -27,7 +27,6 @@ module Guard
|
|
27
27
|
#
|
28
28
|
def start(options)
|
29
29
|
server = options[:server]
|
30
|
-
server = detect_server(options[:spec_dir]) if server == :auto
|
31
30
|
port = options[:port]
|
32
31
|
timeout = options[:server_timeout]
|
33
32
|
|
@@ -54,6 +53,29 @@ module Guard
|
|
54
53
|
end
|
55
54
|
end
|
56
55
|
|
56
|
+
# Detect the server to use
|
57
|
+
#
|
58
|
+
# @param [String] spec_dir the spec directory
|
59
|
+
# @return [Symbol] the server strategy
|
60
|
+
#
|
61
|
+
def detect_server(spec_dir)
|
62
|
+
if File.exists?('config.ru')
|
63
|
+
%w(unicorn thin mongrel).each do |server|
|
64
|
+
begin
|
65
|
+
require server
|
66
|
+
return server.to_sym
|
67
|
+
rescue LoadError
|
68
|
+
# Ignore missing server and try next
|
69
|
+
end
|
70
|
+
end
|
71
|
+
:webrick
|
72
|
+
elsif spec_dir && File.exists?(File.join(spec_dir, 'support', 'jasmine.yml'))
|
73
|
+
:jasmine_gem
|
74
|
+
else
|
75
|
+
:none
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
57
79
|
private
|
58
80
|
|
59
81
|
# Start the Rack server of the current project. This
|
@@ -123,29 +145,6 @@ module Guard
|
|
123
145
|
::Guard::UI.error "Cannot start Rake task server: #{ e.message }"
|
124
146
|
end
|
125
147
|
|
126
|
-
# Detect the server to use
|
127
|
-
#
|
128
|
-
# @param [String] spec_dir the spec directory
|
129
|
-
# @return [Symbol] the server strategy
|
130
|
-
#
|
131
|
-
def detect_server(spec_dir)
|
132
|
-
if File.exists?('config.ru')
|
133
|
-
%w(unicorn thin mongrel).each do |server|
|
134
|
-
begin
|
135
|
-
require server
|
136
|
-
return server.to_sym
|
137
|
-
rescue LoadError
|
138
|
-
# Ignore missing server and try next
|
139
|
-
end
|
140
|
-
end
|
141
|
-
:webrick
|
142
|
-
elsif File.exists?(File.join(spec_dir, 'support', 'jasmine.yml'))
|
143
|
-
:jasmine_gem
|
144
|
-
else
|
145
|
-
:none
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
148
|
# Wait until the Jasmine test server is running.
|
150
149
|
#
|
151
150
|
# @param [Number] port the server port
|
metadata
CHANGED
@@ -1,94 +1,83 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: guard-jasmine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
5
|
-
prerelease:
|
4
|
+
version: 1.15.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Michael Kessler
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-04-
|
11
|
+
date: 2013-04-08 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: guard
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: 1.1.0
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - '>='
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: 1.1.0
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: multi_json
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - '>='
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - '>='
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: childprocess
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - '>='
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: '0'
|
54
48
|
type: :runtime
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - '>='
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: '0'
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: thor
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
|
-
- -
|
59
|
+
- - '>='
|
68
60
|
- !ruby/object:Gem::Version
|
69
61
|
version: '0'
|
70
62
|
type: :runtime
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
|
-
- -
|
66
|
+
- - '>='
|
76
67
|
- !ruby/object:Gem::Version
|
77
68
|
version: '0'
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
70
|
name: bundler
|
80
71
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
72
|
requirements:
|
83
|
-
- -
|
73
|
+
- - '>='
|
84
74
|
- !ruby/object:Gem::Version
|
85
75
|
version: '0'
|
86
76
|
type: :development
|
87
77
|
prerelease: false
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
79
|
requirements:
|
91
|
-
- -
|
80
|
+
- - '>='
|
92
81
|
- !ruby/object:Gem::Version
|
93
82
|
version: '0'
|
94
83
|
description: Guard::Jasmine automatically tests your Jasmine specs on PhantomJS
|
@@ -128,27 +117,26 @@ files:
|
|
128
117
|
- README.md
|
129
118
|
homepage: https://github.com/netzpirat/guard-jasmine
|
130
119
|
licenses: []
|
120
|
+
metadata: {}
|
131
121
|
post_install_message:
|
132
122
|
rdoc_options: []
|
133
123
|
require_paths:
|
134
124
|
- lib
|
135
125
|
required_ruby_version: !ruby/object:Gem::Requirement
|
136
|
-
none: false
|
137
126
|
requirements:
|
138
|
-
- -
|
127
|
+
- - '>='
|
139
128
|
- !ruby/object:Gem::Version
|
140
129
|
version: '0'
|
141
130
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
142
|
-
none: false
|
143
131
|
requirements:
|
144
|
-
- -
|
132
|
+
- - '>='
|
145
133
|
- !ruby/object:Gem::Version
|
146
134
|
version: 1.3.6
|
147
135
|
requirements: []
|
148
136
|
rubyforge_project: guard-jasmine
|
149
|
-
rubygems_version:
|
137
|
+
rubygems_version: 2.0.3
|
150
138
|
signing_key:
|
151
|
-
specification_version:
|
139
|
+
specification_version: 4
|
152
140
|
summary: Guard gem for headless testing with Jasmine
|
153
141
|
test_files: []
|
154
142
|
has_rdoc:
|