guard-jasmine 2.0.6 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +46 -14
- data/lib/generators/guard_jasmine/templates/Guardfile +1 -1
- data/lib/guard/jasmine.rb +6 -7
- data/lib/guard/jasmine/cli.rb +49 -55
- data/lib/guard/jasmine/coverage.rb +4 -2
- data/lib/guard/jasmine/formatter.rb +1 -1
- data/lib/guard/jasmine/inspector.rb +6 -6
- data/lib/guard/jasmine/phantomjs/guard-jasmine.js +23 -3
- data/lib/guard/jasmine/phantomjs/src/guard-jasmine.coffee +15 -2
- data/lib/guard/jasmine/runner.rb +41 -44
- data/lib/guard/jasmine/server.rb +21 -31
- data/lib/guard/jasmine/task.rb +1 -1
- data/lib/guard/jasmine/templates/Guardfile +1 -1
- data/lib/guard/jasmine/util.rb +7 -7
- data/lib/guard/jasmine/version.rb +1 -1
- metadata +9 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 12c271a333b0412865d54f16da8376dbb478abbc
|
4
|
+
data.tar.gz: d07623663f5f1e48c537730e0db93b3283a2d24f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bfe42393a0ac67853b9fec568f60538bb92512edc0fcca210a19e323b445ff9771fac363368728236d74999b32a22a1915f57b02ba2ab64dee575bf60f3498bd
|
7
|
+
data.tar.gz: 20a4cc2b18881720e2befda1a6a9e32108131b6217b22825bff5fc23ac1fe7133a7f94966909d7dff6d2b781905ff95e476e4d9b219427b976f34c6c66c5d3fd
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Guard::Jasmine [![Build Status](https://secure.travis-ci.org/guard/guard-jasmine.png)](
|
1
|
+
# Guard::Jasmine [![Build Status](https://secure.travis-ci.org/guard/guard-jasmine.png)](https://travis-ci.org/guard/guard-jasmine)
|
2
2
|
|
3
3
|
Guard::Jasmine automatically tests your Jasmine specs when files are modified.
|
4
4
|
|
@@ -23,7 +23,7 @@ generate coverage reports.
|
|
23
23
|
|
24
24
|
* Custom console logger implementation for pretty printing JavaScript objects and DOM elements.
|
25
25
|
|
26
|
-
* Can be used to run [Jasmine-species](http://rudylattae.github.
|
26
|
+
* Can be used to run [Jasmine-species](http://rudylattae.github.io/jasmine-species/) acceptance tests provided by
|
27
27
|
[Jasmine Stories](https://github.com/DominikGuzei/jasmine-stories).
|
28
28
|
|
29
29
|
* Thor and Rake command line helper for CI server integration.
|
@@ -40,7 +40,7 @@ for an introduction to Jasmine, Jasminerice and Guard::Jasmine.
|
|
40
40
|
|
41
41
|
### Guard and Guard::Jasmine
|
42
42
|
|
43
|
-
The simplest way to install Guard is to use [Bundler](http://
|
43
|
+
The simplest way to install Guard is to use [Bundler](http://bundler.io).
|
44
44
|
Please make sure to have [Guard][] installed.
|
45
45
|
|
46
46
|
Add Guard::Jasmine to your `Gemfile`:
|
@@ -309,6 +309,38 @@ You can further customize the log output by implement one of these methods:
|
|
309
309
|
In addition, the console can log jQuery collections and outputs the HTML representation of the element by using the
|
310
310
|
jQuery `html()` method.
|
311
311
|
|
312
|
+
### Custom Report options
|
313
|
+
|
314
|
+
Guard::Jasmine supports [custom jasmine reporters](http://jasmine.github.io/2.1/custom_reporter.html). In order to use them you have to configure jasmine and make sure that you add the javascript files to the available assets, in this case I use the ones from [larrymyers/jasmine-reporters](https://github.com/larrymyers/jasmine-reporters):
|
315
|
+
|
316
|
+
```yaml
|
317
|
+
reporters:
|
318
|
+
junit:
|
319
|
+
- "junit_reporter.js"
|
320
|
+
- "junit_reporter.boot.js"
|
321
|
+
```
|
322
|
+
|
323
|
+
junit_reporter.boot.js is the file where you'll have to intialize and configure the reporter:
|
324
|
+
|
325
|
+
```javascript
|
326
|
+
(function() {
|
327
|
+
var reporter = new jasmineReporters.JUnitXmlReporter({
|
328
|
+
// Here you can set any options that the custom reporter accepts
|
329
|
+
savePath: 'reports/junit'
|
330
|
+
});
|
331
|
+
jasmine.getEnv().addReporter(reporter);
|
332
|
+
})();
|
333
|
+
```
|
334
|
+
|
335
|
+
Once you got everything in the right place, run guard-jasmine with --reporters
|
336
|
+
|
337
|
+
#### Making your own reporter write to the filesystem
|
338
|
+
|
339
|
+
If none of the existing reporters work for you, you are writing your own one and you want it to write it's output to the filesystem, you have two options:
|
340
|
+
|
341
|
+
1. use window.__phantom_writeFile(filename, text) (the way [larrymyers/jasmine-reporters](https://github.com/larrymyers/jasmine-reporters) works)
|
342
|
+
2. use window.callPhantom({event: 'writeFile', filename: filename, text: text}) (the way [shepmaster/jasmine-junitreporter](https://github.com/shepmaster/jasmine-junitreporter) works)
|
343
|
+
|
312
344
|
### Coverage options
|
313
345
|
|
314
346
|
Guard::Jasmine supports coverage reports generated by [Istanbul](https://github.com/gotwarlost/istanbul). You need to
|
@@ -330,7 +362,7 @@ coverage: true # Enable/disable JavaScript covera
|
|
330
362
|
Istanbul needs to instrument the implementation files so that the execution path can be detected. Guard::Jasmine comes
|
331
363
|
with a tilt template that generates instrumented implementation files when using in the asset pipeline. If you do not
|
332
364
|
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
|
333
|
-
[Guard::Process](https://github.com/
|
365
|
+
[Guard::Process](https://github.com/guard/guard-process). You can get more information about the
|
334
366
|
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.
|
335
367
|
|
336
368
|
**Important**: You need to clear the asset cache when you change this setting, so that already compiled assets will be
|
@@ -413,7 +445,7 @@ end
|
|
413
445
|
These options affects what system notifications are shown after a spec run:
|
414
446
|
|
415
447
|
```ruby
|
416
|
-
|
448
|
+
notification: false # Show success and error notifications.
|
417
449
|
# default: true
|
418
450
|
|
419
451
|
hide_success: true # Disable successful spec run notification.
|
@@ -545,7 +577,7 @@ $ rake guard:jasmine
|
|
545
577
|
|
546
578
|
### Travis CI integration
|
547
579
|
|
548
|
-
With the given `guard-jasmine` script you're able to configure [Travis CI](
|
580
|
+
With the given `guard-jasmine` script you're able to configure [Travis CI](https://travis-ci.org/) to run Guard::Jasmine.
|
549
581
|
Simply use the `script` setting in your `.travis.yml`:
|
550
582
|
|
551
583
|
```yaml
|
@@ -614,7 +646,7 @@ When you file an issue, please try to follow to these simple rules if applicable
|
|
614
646
|
|
615
647
|
## Development information
|
616
648
|
|
617
|
-
- Documentation hosted at [RubyDoc](http://rubydoc.info/github/guard/guard-jasmine/master/frames).
|
649
|
+
- Documentation hosted at [RubyDoc](http://www.rubydoc.info/github/guard/guard-jasmine/master/frames).
|
618
650
|
- Source hosted at [GitHub](https://github.com/guard/guard-jasmine).
|
619
651
|
|
620
652
|
Pull requests are very welcome! Please try to follow these simple rules if applicable:
|
@@ -710,20 +742,20 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
710
742
|
[Guard]: https://github.com/guard/guard
|
711
743
|
[Guards]: https://github.com/guard
|
712
744
|
[Guard Team]: https://github.com/guard/guard/contributors
|
713
|
-
[Ariya Hidayat]:
|
745
|
+
[Ariya Hidayat]: https://twitter.com/#!/AriyaHidayat
|
714
746
|
[PhantomJS]: http://www.phantomjs.org/
|
715
747
|
[the PhantomJS download section]: http://code.google.com/p/phantomjs/downloads/list
|
716
748
|
[PhantomJS build instructions]: http://code.google.com/p/phantomjs/wiki/BuildInstructions
|
717
|
-
[Brad Phelan]:
|
749
|
+
[Brad Phelan]: https://twitter.com/#!/bradgonesurfing
|
718
750
|
[Jasminerice]: https://github.com/bradphelan/jasminerice
|
719
751
|
[jasmine-rails]: https://github.com/searls/jasmine-rails
|
720
752
|
[Pivotal Labs]: http://pivotallabs.com/
|
721
753
|
[Jasmine]: http://pivotal.github.com/jasmine/
|
722
754
|
[the Jasmine Gem]: https://github.com/pivotal/jasmine-gem
|
723
|
-
[Jeremy Ashkenas]:
|
724
|
-
[CoffeeScript]: http://
|
755
|
+
[Jeremy Ashkenas]: https://twitter.com/#!/jashkenas
|
756
|
+
[CoffeeScript]: http://coffeescript.org/
|
725
757
|
[Rails 3.1 asset pipeline]: http://guides.rubyonrails.org/asset_pipeline.html
|
726
|
-
[Homebrew]: http://
|
758
|
+
[Homebrew]: http://brew.sh/
|
727
759
|
[PhantomJS script]: https://github.com/netzpirat/guard-jasmine/blob/master/lib/guard/jasmine/phantomjs/guard-jasmine.coffee
|
728
760
|
[Guard::CoffeeScript]: https://github.com/guard/guard-coffeescript
|
729
761
|
[Sinon.JS]: http://sinonjs.org
|
@@ -731,5 +763,5 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
731
763
|
[guard-konacha]: https://github.com/alexgb/guard-konacha
|
732
764
|
[konacha]: https://github.com/jfirebaugh/konacha
|
733
765
|
[Karma]: https://github.com/karma-runner/karma
|
734
|
-
[guard-teabag]: https://github.com/modeset/guard-
|
735
|
-
[Teabag]: https://github.com/modeset/
|
766
|
+
[guard-teabag]: https://github.com/modeset/guard-teaspoon
|
767
|
+
[Teabag]: https://github.com/modeset/teaspoon
|
@@ -4,6 +4,6 @@
|
|
4
4
|
guard :jasmine do
|
5
5
|
watch(%r{^spec/javascripts/.*(?:_s|S)pec\.(coffee|js)$})
|
6
6
|
watch(%r{app/assets/javascripts/(.+?)\.(js\.coffee|js|coffee)(?:\.\w+)*$}) do |m|
|
7
|
-
"spec/javascripts/jasmine/#{
|
7
|
+
"spec/javascripts/jasmine/#{m[1]}_spec.#{m[2]}"
|
8
8
|
end
|
9
9
|
end
|
data/lib/guard/jasmine.rb
CHANGED
@@ -22,7 +22,7 @@ module Guard
|
|
22
22
|
server: :auto,
|
23
23
|
server_env: ENV['RAILS_ENV'] || 'development',
|
24
24
|
server_timeout: 60,
|
25
|
-
server_mount: '/jasmine',
|
25
|
+
server_mount: '/jasmine', # set here for documentation purposes; actually determiend at runtime by presence (or lack thereof) of the JasmineRails constant
|
26
26
|
port: nil,
|
27
27
|
rackup_config: nil,
|
28
28
|
jasmine_url: nil,
|
@@ -47,11 +47,9 @@ module Guard
|
|
47
47
|
functions_threshold: 0,
|
48
48
|
branches_threshold: 0,
|
49
49
|
lines_threshold: 0,
|
50
|
-
|
51
|
-
junit_consolidate: true,
|
52
|
-
junit_save_path: '',
|
50
|
+
reporters: nil,
|
53
51
|
debug: false
|
54
|
-
}
|
52
|
+
}.freeze
|
55
53
|
|
56
54
|
# Initialize Guard::Jasmine.
|
57
55
|
#
|
@@ -93,9 +91,9 @@ module Guard
|
|
93
91
|
|
94
92
|
options[:spec_dir] ||= File.exist?(File.join('spec', 'javascripts')) ? File.join('spec', 'javascripts') : 'spec'
|
95
93
|
options[:server] ||= :auto
|
96
|
-
options[:server]
|
94
|
+
options[:server] = ::Guard::Jasmine::Server.detect_server(options[:spec_dir]) if options[:server] == :auto
|
97
95
|
options[:port] ||= ::Guard::Jasmine::Server.choose_server_port(options)
|
98
|
-
options[:jasmine_url] = "http://localhost:#{
|
96
|
+
options[:jasmine_url] = "http://localhost:#{options[:port]}#{options[:server] == :jasmine_gem ? '/' : options[:server_mount]}" unless options[:jasmine_url]
|
99
97
|
options[:specdoc] = :failure unless [:always, :never, :failure].include? options[:specdoc]
|
100
98
|
options[:phantomjs_bin] = Jasmine.which('phantomjs') unless options[:phantomjs_bin]
|
101
99
|
|
@@ -152,6 +150,7 @@ module Guard
|
|
152
150
|
|
153
151
|
throw :task_has_failed if last_run_failed
|
154
152
|
end
|
153
|
+
|
155
154
|
# Gets called when watched paths and files have changes.
|
156
155
|
#
|
157
156
|
# @param [Array<String>] paths the changed paths and files
|
data/lib/guard/jasmine/cli.rb
CHANGED
@@ -150,20 +150,11 @@ module Guard
|
|
150
150
|
default: 0,
|
151
151
|
desc: 'Lines coverage threshold'
|
152
152
|
|
153
|
-
method_option :
|
154
|
-
type: :boolean,
|
155
|
-
default: false,
|
156
|
-
desc: 'Whether to save jasmine test results in JUnit-compatible xml files'
|
157
|
-
|
158
|
-
method_option :junit_consolidate,
|
159
|
-
type: :boolean,
|
160
|
-
default: false,
|
161
|
-
desc: 'Whether to save nested describes within the same xml file as their parent'
|
162
|
-
|
163
|
-
method_option :junit_save_path,
|
153
|
+
method_option :reporters,
|
164
154
|
type: :string,
|
165
|
-
default:
|
166
|
-
desc: '
|
155
|
+
default: nil,
|
156
|
+
desc: 'Comma separated list of jasmine reporters to use'
|
157
|
+
|
167
158
|
|
168
159
|
# Run the Guard::Jasmine::Runner with options from
|
169
160
|
# the command line.
|
@@ -171,49 +162,14 @@ module Guard
|
|
171
162
|
# @param [Array<String>] paths the name of the specs to run
|
172
163
|
#
|
173
164
|
def spec(*paths)
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
runner_options[:line_number] = options.line_number
|
178
|
-
runner_options[:server] = options.server.to_sym == :auto ? ::Guard::Jasmine::Server.detect_server(runner_options[:spec_dir]) : options.server.to_sym
|
179
|
-
runner_options[:server_mount] = options.mount || (defined?(JasmineRails) ? '/specs' : '/jasmine')
|
180
|
-
runner_options[:jasmine_url] = options.url || "http://localhost:#{ runner_options[:port] }#{ options.server.to_sym == :jasmine_gem ? '/' : runner_options[:server_mount] }"
|
181
|
-
runner_options[:phantomjs_bin] = options.bin || CLI.which('phantomjs')
|
182
|
-
runner_options[:timeout] = options.timeout
|
183
|
-
runner_options[:verbose] = options.verbose
|
184
|
-
runner_options[:server_env] = options.server_env
|
185
|
-
runner_options[:server_timeout] = options.server_timeout
|
186
|
-
runner_options[:rackup_config] = options.rackup_config
|
187
|
-
runner_options[:console] = [:always, :never, :failure].include?(options.console.to_sym) ? options.console.to_sym : :failure
|
188
|
-
runner_options[:errors] = [:always, :never, :failure].include?(options.errors.to_sym) ? options.errors.to_sym : :failure
|
189
|
-
runner_options[:specdoc] = [:always, :never, :failure].include?(options.specdoc.to_sym) ? options.specdoc.to_sym : :always
|
190
|
-
runner_options[:focus] = options.focus
|
191
|
-
runner_options[:coverage] = options.coverage || options.coverage_html || options.coverage_summary || options.coverage_html_dir != './coverage'
|
192
|
-
runner_options[:coverage_html] = options.coverage_html || options.coverage_html_dir != './coverage'
|
193
|
-
runner_options[:coverage_html_dir] = options.coverage_html_dir
|
194
|
-
runner_options[:coverage_summary] = options.coverage_summary
|
195
|
-
runner_options[:ignore_instrumentation] = options.ignore_instrumentation
|
196
|
-
runner_options[:statements_threshold] = options.statements_threshold
|
197
|
-
runner_options[:functions_threshold] = options.functions_threshold
|
198
|
-
runner_options[:branches_threshold] = options.branches_threshold
|
199
|
-
runner_options[:lines_threshold] = options.lines_threshold
|
200
|
-
runner_options[:notification] = false
|
201
|
-
runner_options[:hide_success] = true
|
202
|
-
runner_options[:max_error_notify] = 0
|
203
|
-
runner_options[:junit] = options.junit
|
204
|
-
runner_options[:junit_consolidate] = options.junit_consolidate
|
205
|
-
runner_options[:junit_save_path] = options.junit_save_path
|
206
|
-
runner_options[:is_cli] = true
|
207
|
-
|
208
|
-
paths = [runner_options[:spec_dir]] if paths.empty?
|
209
|
-
|
210
|
-
if CLI.phantomjs_bin_valid?(runner_options[:phantomjs_bin])
|
165
|
+
options = runner_options
|
166
|
+
paths = [options[:spec_dir]] if paths.empty?
|
167
|
+
if CLI.phantomjs_bin_valid?(options[:phantomjs_bin])
|
211
168
|
catch(:task_has_failed) do
|
212
|
-
::Guard::Jasmine::Server.start(
|
169
|
+
::Guard::Jasmine::Server.start(options) unless options[:server] == :none
|
213
170
|
end
|
214
|
-
|
215
|
-
|
216
|
-
result = ::Guard::Jasmine::Runner.new(runner_options).run(paths)
|
171
|
+
if CLI.runner_available?(options)
|
172
|
+
result = ::Guard::Jasmine::Runner.new(options).run(paths)
|
217
173
|
::Guard::Jasmine::Server.stop
|
218
174
|
Process.exit result.empty? ? 0 : 1
|
219
175
|
else
|
@@ -239,8 +195,46 @@ module Guard
|
|
239
195
|
# @see Guard::Jasmine::VERSION
|
240
196
|
#
|
241
197
|
def version
|
242
|
-
Compat::UI.info "Guard::Jasmine version #{
|
198
|
+
Compat::UI.info "Guard::Jasmine version #{::Guard::JasmineVersion::VERSION}"
|
243
199
|
end
|
200
|
+
|
201
|
+
private
|
202
|
+
|
203
|
+
def runner_options
|
204
|
+
ro = {}
|
205
|
+
ro[:port] = options.port || CLI.find_free_server_port
|
206
|
+
ro[:spec_dir] = options.spec_dir || (File.exist?(File.join('spec', 'javascripts')) ? File.join('spec', 'javascripts') : 'spec')
|
207
|
+
ro[:line_number] = options.line_number
|
208
|
+
ro[:server] = options.server.to_sym == :auto ? ::Guard::Jasmine::Server.detect_server(ro[:spec_dir]) : options.server.to_sym
|
209
|
+
ro[:server_mount] = options.mount || (defined?(JasmineRails) ? '/specs' : '/jasmine')
|
210
|
+
ro[:jasmine_url] = options.url || "http://localhost:#{ro[:port]}#{options.server.to_sym == :jasmine_gem ? '/' : ro[:server_mount]}"
|
211
|
+
ro[:phantomjs_bin] = options.bin || CLI.which('phantomjs')
|
212
|
+
ro[:timeout] = options.timeout
|
213
|
+
ro[:verbose] = options.verbose
|
214
|
+
ro[:server_env] = options.server_env
|
215
|
+
ro[:server_timeout] = options.server_timeout
|
216
|
+
ro[:rackup_config] = options.rackup_config
|
217
|
+
ro[:console] = [:always, :never, :failure].include?(options.console.to_sym) ? options.console.to_sym : :failure
|
218
|
+
ro[:errors] = [:always, :never, :failure].include?(options.errors.to_sym) ? options.errors.to_sym : :failure
|
219
|
+
ro[:specdoc] = [:always, :never, :failure].include?(options.specdoc.to_sym) ? options.specdoc.to_sym : :always
|
220
|
+
ro[:focus] = options.focus
|
221
|
+
ro[:coverage] = options.coverage || options.coverage_html || options.coverage_summary || options.coverage_html_dir != './coverage'
|
222
|
+
ro[:coverage_html] = options.coverage_html || options.coverage_html_dir != './coverage'
|
223
|
+
ro[:coverage_html_dir] = options.coverage_html_dir
|
224
|
+
ro[:coverage_summary] = options.coverage_summary
|
225
|
+
ro[:ignore_instrumentation] = options.ignore_instrumentation
|
226
|
+
ro[:statements_threshold] = options.statements_threshold
|
227
|
+
ro[:functions_threshold] = options.functions_threshold
|
228
|
+
ro[:branches_threshold] = options.branches_threshold
|
229
|
+
ro[:lines_threshold] = options.lines_threshold
|
230
|
+
ro[:notification] = false
|
231
|
+
ro[:hide_success] = true
|
232
|
+
ro[:max_error_notify] = 0
|
233
|
+
ro[:query_params] = options.reporters ? { reporters: options.reporters } : nil
|
234
|
+
ro[:is_cli] = true
|
235
|
+
ro
|
236
|
+
end
|
237
|
+
|
244
238
|
end
|
245
239
|
end
|
246
240
|
end
|
@@ -28,7 +28,7 @@ class JasmineCoverage < Tilt::Template
|
|
28
28
|
|
29
29
|
result = `#{JasmineCoverage.coverage_bin} instrument --embed-source #{input.shellescape}`
|
30
30
|
|
31
|
-
|
31
|
+
raise "Could not generate coverage instrumented file for #{file}" unless $CHILD_STATUS.exitstatus.zero?
|
32
32
|
|
33
33
|
result.gsub input, file
|
34
34
|
end
|
@@ -60,7 +60,9 @@ if ENV['COVERAGE'] == 'true' && defined?(Rails)
|
|
60
60
|
#
|
61
61
|
class GuardJasmineCoverageEngine < ::Rails::Engine
|
62
62
|
initializer 'guard-jasmine.initialize' do |app|
|
63
|
-
app.assets.
|
63
|
+
app.config.assets.configure do |env|
|
64
|
+
env.register_postprocessor 'application/javascript', JasmineCoverage
|
65
|
+
end
|
64
66
|
end
|
65
67
|
end
|
66
68
|
|
@@ -95,7 +95,7 @@ module Guard
|
|
95
95
|
# @param [String] color_code the color code
|
96
96
|
#
|
97
97
|
def color(text, color_code)
|
98
|
-
Compat::UI.color_enabled? ? "\e[0#{
|
98
|
+
Compat::UI.color_enabled? ? "\e[0#{color_code}m#{text}\e[0m" : text
|
99
99
|
end
|
100
100
|
end
|
101
101
|
end
|
@@ -20,11 +20,11 @@ module Guard
|
|
20
20
|
def clean(paths, options)
|
21
21
|
paths.uniq!
|
22
22
|
paths.compact!
|
23
|
-
if paths.include?(options[:spec_dir])
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
23
|
+
paths = if paths.include?(options[:spec_dir])
|
24
|
+
[options[:spec_dir]]
|
25
|
+
else
|
26
|
+
paths.select { |p| jasmine_spec?(p) }
|
27
|
+
end
|
28
28
|
|
29
29
|
paths
|
30
30
|
end
|
@@ -37,7 +37,7 @@ module Guard
|
|
37
37
|
# @return [Boolean] when the file valid
|
38
38
|
#
|
39
39
|
def jasmine_spec?(path)
|
40
|
-
path =~ /(?:_s|S)pec\.(js|coffee|js\.coffee)$/ && File.exist?(path)
|
40
|
+
path =~ /(?:_s|S)pec\.(js|coffee|js\.coffee|cjsx|js\.cjsx)$/ && File.exist?(path)
|
41
41
|
end
|
42
42
|
end
|
43
43
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
(function() {
|
2
|
-
var exitError, exitSuccessfully, hasLoggedError, jasmineAvailable, options, page, phantomExit, reportError, reporterMissing, reporterReady, specsDone, specsTimedout, system, waitFor;
|
2
|
+
var exitError, exitSuccessfully, fs, hasLoggedError, jasmineAvailable, options, page, phantomExit, reportError, reporterMissing, reporterReady, specsDone, specsTimedout, system, waitFor;
|
3
3
|
|
4
4
|
system = require('system');
|
5
5
|
|
@@ -10,6 +10,8 @@
|
|
10
10
|
|
11
11
|
page = require('webpage').create();
|
12
12
|
|
13
|
+
fs = require('fs');
|
14
|
+
|
13
15
|
page.onError = function(message, trace) {
|
14
16
|
return reportError("Javascript error encountered on Jasmine test page: " + message, trace);
|
15
17
|
};
|
@@ -20,15 +22,25 @@
|
|
20
22
|
};
|
21
23
|
|
22
24
|
page.onInitialized = function() {
|
25
|
+
var injectReporter;
|
23
26
|
page.injectJs('guard-reporter.js');
|
24
|
-
|
27
|
+
injectReporter = function(pathSeparator) {
|
25
28
|
return window.onload = function() {
|
26
29
|
window.reporter = new GuardReporter();
|
30
|
+
window.fs_path_separator = "" + pathSeparator;
|
31
|
+
window.__phantom_writeFile = function(filename, text) {
|
32
|
+
return window.callPhantom({
|
33
|
+
event: 'writeFile',
|
34
|
+
filename: filename,
|
35
|
+
text: text
|
36
|
+
});
|
37
|
+
};
|
27
38
|
if (window.jasmine) {
|
28
39
|
return window.jasmine.getEnv().addReporter(window.reporter);
|
29
40
|
}
|
30
41
|
};
|
31
|
-
}
|
42
|
+
};
|
43
|
+
return page.evaluate(injectReporter, fs.separator);
|
32
44
|
};
|
33
45
|
|
34
46
|
page.onLoadFinished = function(status) {
|
@@ -39,6 +51,14 @@
|
|
39
51
|
}
|
40
52
|
};
|
41
53
|
|
54
|
+
page.onCallback = function(data) {
|
55
|
+
if (data.event === 'writeFile') {
|
56
|
+
return fs.write(data.filename, data.text, 'w');
|
57
|
+
} else {
|
58
|
+
return console.log('unknown event callback: ' + data.event);
|
59
|
+
}
|
60
|
+
};
|
61
|
+
|
42
62
|
page.open(options.url);
|
43
63
|
|
44
64
|
reporterReady = function() {
|
@@ -9,6 +9,9 @@ options =
|
|
9
9
|
# Create the web page.
|
10
10
|
page = require('webpage').create()
|
11
11
|
|
12
|
+
# Define fs to write files for custom reporters
|
13
|
+
fs = require('fs')
|
14
|
+
|
12
15
|
# Catch JavaScript errors
|
13
16
|
# abort the request and return the error
|
14
17
|
page.onError = (message, trace) ->
|
@@ -22,18 +25,28 @@ page.onResourceError = (error)->
|
|
22
25
|
# the GuardReporter class
|
23
26
|
page.onInitialized = ->
|
24
27
|
page.injectJs 'guard-reporter.js'
|
25
|
-
|
28
|
+
injectReporter = (pathSeparator) ->
|
26
29
|
window.onload = ->
|
27
30
|
window.reporter = new GuardReporter()
|
31
|
+
window.fs_path_separator = "#{pathSeparator}"
|
32
|
+
window.__phantom_writeFile = (filename, text) ->
|
33
|
+
window.callPhantom({event: 'writeFile', filename: filename, text: text})
|
28
34
|
window.jasmine.getEnv().addReporter(window.reporter) if window.jasmine
|
35
|
+
page.evaluate injectReporter, fs.separator
|
29
36
|
|
30
37
|
# Once the page is finished loading
|
31
|
-
page.onLoadFinished = (status)->
|
38
|
+
page.onLoadFinished = (status) ->
|
32
39
|
if status isnt 'success'
|
33
40
|
reportError "Unable to access Jasmine specs at #{page.reason_url}. #{page.reason}"
|
34
41
|
else
|
35
42
|
waitFor reporterReady, jasmineAvailable, options.timeout, reporterMissing
|
36
43
|
|
44
|
+
page.onCallback = (data) ->
|
45
|
+
if data.event is 'writeFile'
|
46
|
+
fs.write(data.filename, data.text, 'w')
|
47
|
+
else
|
48
|
+
console.log('unknown event callback: ' + data.event)
|
49
|
+
|
37
50
|
# Open web page, which will kick off the Jasmine test runner
|
38
51
|
page.open options.url
|
39
52
|
|
data/lib/guard/jasmine/runner.rb
CHANGED
@@ -19,7 +19,7 @@ module Guard
|
|
19
19
|
attr_reader :options
|
20
20
|
|
21
21
|
# Name of the coverage threshold options
|
22
|
-
THRESHOLDS = [:statements_threshold, :functions_threshold, :branches_threshold, :lines_threshold]
|
22
|
+
THRESHOLDS = [:statements_threshold, :functions_threshold, :branches_threshold, :lines_threshold].freeze
|
23
23
|
|
24
24
|
# Run the supplied specs.
|
25
25
|
#
|
@@ -58,7 +58,7 @@ module Guard
|
|
58
58
|
end
|
59
59
|
end
|
60
60
|
# return the errors
|
61
|
-
return run_results.each_with_object({}) do |
|
61
|
+
return run_results.each_with_object({}) do |spec_run, hash|
|
62
62
|
file, r = spec_run
|
63
63
|
errors = collect_spec_errors(r['suites'] || [])
|
64
64
|
errors.push(r['error']) if r.key? 'error'
|
@@ -78,7 +78,7 @@ module Guard
|
|
78
78
|
message = if paths == [options[:spec_dir]]
|
79
79
|
'Run all Jasmine suites'
|
80
80
|
else
|
81
|
-
"Run Jasmine suite#{
|
81
|
+
"Run Jasmine suite#{paths.size == 1 ? '' : 's'} #{paths.join(' ')}"
|
82
82
|
end
|
83
83
|
|
84
84
|
Formatter.info(message, reset: true)
|
@@ -94,7 +94,7 @@ module Guard
|
|
94
94
|
arguments = [
|
95
95
|
options[:timeout] * 1000
|
96
96
|
]
|
97
|
-
cmd = "#{
|
97
|
+
cmd = "#{phantomjs_command} \"#{suite}\" #{arguments.collect(&:to_s).join(' ')}"
|
98
98
|
puts cmd if options[:debug]
|
99
99
|
IO.popen(cmd, 'r:UTF-8')
|
100
100
|
end
|
@@ -206,7 +206,7 @@ module Guard
|
|
206
206
|
#
|
207
207
|
def it_and_describe_lines(file, from, to)
|
208
208
|
File.readlines(file)[from, to]
|
209
|
-
|
209
|
+
.select { |x| x =~ /^\s*(it|describe)/ }
|
210
210
|
end
|
211
211
|
|
212
212
|
# Extracts the title of a 'description' or a 'it' declaration.
|
@@ -229,13 +229,14 @@ module Guard
|
|
229
229
|
def evaluate_response(output, file)
|
230
230
|
json = output.read
|
231
231
|
json = json.encode('UTF-8') if json.respond_to?(:encode)
|
232
|
+
json = json.gsub(/Unsafe JavaScript.*/, '')
|
232
233
|
begin
|
233
|
-
result = MultiJson.decode(json,
|
234
|
-
|
234
|
+
result = MultiJson.decode(json, max_nesting: false)
|
235
|
+
raise 'No response from Jasmine runner' if !result && options[:is_cli]
|
235
236
|
pp result if options[:debug]
|
236
237
|
if result['error']
|
237
238
|
if options[:is_cli]
|
238
|
-
|
239
|
+
raise "Runner error: #{result['error']}"
|
239
240
|
else
|
240
241
|
notify_runtime_error(result)
|
241
242
|
end
|
@@ -257,14 +258,12 @@ module Guard
|
|
257
258
|
else
|
258
259
|
Formatter.error('No response from the Jasmine runner!')
|
259
260
|
end
|
261
|
+
elsif options[:is_cli]
|
262
|
+
raise "Cannot decode JSON from PhantomJS runner, message received was:\n#{json}"
|
260
263
|
else
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
Formatter.error("Cannot decode JSON from PhantomJS runner: #{ e.message }")
|
265
|
-
Formatter.error("JSON response: #{ e.data }")
|
266
|
-
Formatter.error("message received was:\n#{json}")
|
267
|
-
end
|
264
|
+
Formatter.error("Cannot decode JSON from PhantomJS runner: #{e.message}")
|
265
|
+
Formatter.error("JSON response: #{e.data}")
|
266
|
+
Formatter.error("message received was:\n#{json}")
|
268
267
|
end
|
269
268
|
ensure
|
270
269
|
output.close
|
@@ -277,7 +276,7 @@ module Guard
|
|
277
276
|
# @param [Hash] result the suite result
|
278
277
|
#
|
279
278
|
def notify_runtime_error(result)
|
280
|
-
message = "An error occurred: #{
|
279
|
+
message = "An error occurred: #{result['error']}"
|
281
280
|
Formatter.error(message)
|
282
281
|
Formatter.error(result['trace']) if result['trace']
|
283
282
|
Formatter.notify(message, title: 'Jasmine error', image: :failed, priority: 2) if options[:notification]
|
@@ -291,14 +290,14 @@ module Guard
|
|
291
290
|
def notify_spec_result(result)
|
292
291
|
specs = result['stats']['specs'] - result['stats']['disabled']
|
293
292
|
failed = result['stats']['failed']
|
294
|
-
time =
|
293
|
+
time = format('%0.2f', result['stats']['time'])
|
295
294
|
specs_plural = specs == 1 ? '' : 's'
|
296
295
|
failed_plural = failed == 1 ? '' : 's'
|
297
|
-
Formatter.info("Finished in #{
|
296
|
+
Formatter.info("Finished in #{time} seconds")
|
298
297
|
pending = result['stats']['pending'].to_i > 0 ? " #{result['stats']['pending']} pending," : ''
|
299
|
-
message = "#{
|
300
|
-
full_message = "#{
|
301
|
-
passed = failed
|
298
|
+
message = "#{specs} spec#{specs_plural},#{pending} #{failed} failure#{failed_plural}"
|
299
|
+
full_message = "#{message}\nin #{time} seconds"
|
300
|
+
passed = failed.zero?
|
302
301
|
|
303
302
|
report_specdoc(result, passed) if specdoc_shown?(passed)
|
304
303
|
|
@@ -374,7 +373,7 @@ module Guard
|
|
374
373
|
if any_coverage_threshold?
|
375
374
|
coverage = `#{coverage_bin} check-coverage #{ istanbul_coverage_options } #{ coverage_file } 2>&1`
|
376
375
|
coverage = coverage.split("\n").grep(/ERROR/).join.sub('ERROR:', '')
|
377
|
-
failed = $CHILD_STATUS && $CHILD_STATUS.exitstatus
|
376
|
+
failed = $CHILD_STATUS && $CHILD_STATUS.exitstatus.nonzero?
|
378
377
|
|
379
378
|
if failed
|
380
379
|
Formatter.error coverage
|
@@ -392,7 +391,7 @@ module Guard
|
|
392
391
|
def generate_html_report
|
393
392
|
report_directory = coverage_report_directory
|
394
393
|
`#{coverage_bin} report --dir #{ report_directory } --root #{ coverage_root } html #{ coverage_file }`
|
395
|
-
Formatter.info "Updated HTML report available at: #{
|
394
|
+
Formatter.info "Updated HTML report available at: #{report_directory}/index.html"
|
396
395
|
end
|
397
396
|
|
398
397
|
# Uses the Istanbul text-summary reporter to output the
|
@@ -437,11 +436,11 @@ module Guard
|
|
437
436
|
# If the focus option is set, then only failing tests are shown
|
438
437
|
next unless :always == options[:specdoc] || spec['status'] == 'failed' || (!run_passed && !options[:focus])
|
439
438
|
if spec['status'] == 'passed'
|
440
|
-
Formatter.success(indent(" ✔ #{
|
439
|
+
Formatter.success(indent(" ✔ #{spec['description']}", level))
|
441
440
|
elsif spec['status'] == 'failed'
|
442
|
-
Formatter.spec_failed(indent(" ✘ #{
|
441
|
+
Formatter.spec_failed(indent(" ✘ #{spec['description']}", level))
|
443
442
|
else
|
444
|
-
Formatter.spec_pending(indent(" ○ #{
|
443
|
+
Formatter.spec_pending(indent(" ○ #{spec['description']}", level))
|
445
444
|
end
|
446
445
|
report_specdoc_errors(spec, level)
|
447
446
|
report_specdoc_logs(spec, level)
|
@@ -493,7 +492,7 @@ module Guard
|
|
493
492
|
if console_for_spec?(spec)
|
494
493
|
spec['logs'].each do |log_level, message|
|
495
494
|
log_level = log_level == 'log' ? '' : "#{log_level.upcase}: "
|
496
|
-
Formatter.info(indent(" • #{log_level}#{
|
495
|
+
Formatter.info(indent(" • #{log_level}#{message}", level))
|
497
496
|
end
|
498
497
|
end
|
499
498
|
end
|
@@ -507,11 +506,11 @@ module Guard
|
|
507
506
|
return unless spec['errors'] && (options[:errors] == :always || (options[:errors] == :failure && spec['status'] == 'failed'))
|
508
507
|
|
509
508
|
spec['errors'].each do |error|
|
510
|
-
Formatter.spec_failed(indent(" ➤ #{
|
509
|
+
Formatter.spec_failed(indent(" ➤ #{format_error(error, true)}", level))
|
511
510
|
next unless error['trace']
|
512
511
|
|
513
512
|
error['trace'].each do |trace|
|
514
|
-
Formatter.spec_failed(indent(" ➜ #{
|
513
|
+
Formatter.spec_failed(indent(" ➜ #{trace['file']} on line #{trace['line']}", level + 2))
|
515
514
|
end
|
516
515
|
end
|
517
516
|
end
|
@@ -565,7 +564,7 @@ module Guard
|
|
565
564
|
#
|
566
565
|
def format_error(error, short)
|
567
566
|
message = error['message'].gsub(%r{ in http.*\(line \d+\)$}, '')
|
568
|
-
if !short && error['trace'] && error['trace'].
|
567
|
+
if !short && error['trace'] && !error['trace'].empty?
|
569
568
|
location = error['trace'][0]
|
570
569
|
"#{message} in #{location['file']}:#{location['line']}"
|
571
570
|
else
|
@@ -581,20 +580,18 @@ module Guard
|
|
581
580
|
#
|
582
581
|
def update_coverage(coverage, file)
|
583
582
|
if file == options[:spec_dir]
|
584
|
-
File.write(coverage_file, MultiJson.encode(coverage,
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
coverage = MultiJson.decode(File.read(coverage_file), max_nesting: false)
|
583
|
+
File.write(coverage_file, MultiJson.encode(coverage, max_nesting: false))
|
584
|
+
elsif File.exist?(coverage_file)
|
585
|
+
impl = file.sub('_spec', '').sub(options[:spec_dir], '')
|
586
|
+
coverage = MultiJson.decode(File.read(coverage_file), max_nesting: false)
|
589
587
|
|
590
|
-
|
591
|
-
|
592
|
-
end
|
593
|
-
|
594
|
-
File.write(coverage_file, MultiJson.encode(coverage, max_nesting: false))
|
595
|
-
else
|
596
|
-
File.write(coverage_file, MultiJson.encode({}))
|
588
|
+
coverage.each do |coverage_file, data|
|
589
|
+
coverage[coverage_file] = data if coverage_file == impl
|
597
590
|
end
|
591
|
+
|
592
|
+
File.write(coverage_file, MultiJson.encode(coverage, max_nesting: false))
|
593
|
+
else
|
594
|
+
File.write(coverage_file, MultiJson.encode({}))
|
598
595
|
end
|
599
596
|
end
|
600
597
|
|
@@ -603,7 +600,7 @@ module Guard
|
|
603
600
|
# @return [Boolean] true if any coverage threshold is set
|
604
601
|
#
|
605
602
|
def any_coverage_threshold?
|
606
|
-
THRESHOLDS.any? { |threshold| options[threshold]
|
603
|
+
THRESHOLDS.any? { |threshold| options[threshold].nonzero? }
|
607
604
|
end
|
608
605
|
|
609
606
|
# Converts the options to Istanbul recognized options
|
@@ -613,7 +610,7 @@ module Guard
|
|
613
610
|
def istanbul_coverage_options
|
614
611
|
THRESHOLDS.inject([]) do |coverage, name|
|
615
612
|
threshold = options[name]
|
616
|
-
coverage << (threshold
|
613
|
+
coverage << (threshold.nonzero? ? "--#{name.to_s.sub('_threshold', '')} #{threshold}" : '')
|
617
614
|
end.reject(&:empty?).join(' ')
|
618
615
|
end
|
619
616
|
|
data/lib/guard/jasmine/server.rb
CHANGED
@@ -14,8 +14,7 @@ module Guard
|
|
14
14
|
#
|
15
15
|
module Server
|
16
16
|
class << self
|
17
|
-
attr_accessor :process
|
18
|
-
attr_accessor :cmd
|
17
|
+
attr_accessor :process, :cmd
|
19
18
|
# Start the internal test server for getting the Jasmine runner.
|
20
19
|
#
|
21
20
|
# @param [Hash] options the server options
|
@@ -27,31 +26,29 @@ module Guard
|
|
27
26
|
# @option options [String] rackup_config custom rackup config to use (i.e. spec/dummy/config.ru for mountable engines)
|
28
27
|
#
|
29
28
|
def start(options)
|
30
|
-
|
31
|
-
port = options[:port]
|
32
|
-
timeout = options[:server_timeout]
|
29
|
+
port = options[:port]
|
33
30
|
|
34
|
-
case server
|
31
|
+
case options[:server]
|
35
32
|
when :webrick, :mongrel, :thin, :puma
|
36
|
-
start_rack_server(server, port, options)
|
33
|
+
start_rack_server(options[:server], port, options)
|
37
34
|
when :unicorn
|
38
35
|
start_unicorn_server(port, options)
|
39
36
|
when :jasmine_gem
|
40
37
|
start_rake_server(port, 'jasmine', options)
|
38
|
+
when :none # noop
|
41
39
|
else
|
42
|
-
start_rake_server(port, server
|
40
|
+
start_rake_server(port, options[:server], options)
|
43
41
|
end
|
44
42
|
|
45
|
-
wait_for_server(port,
|
43
|
+
wait_for_server(port, options[:server_timeout]) unless options[:server] == :none
|
46
44
|
end
|
47
45
|
|
48
46
|
# Stop the server thread.
|
49
47
|
#
|
50
48
|
def stop
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
end
|
49
|
+
return unless process
|
50
|
+
Compat::UI.info 'Guard::Jasmine stops server.'
|
51
|
+
process.stop(5)
|
55
52
|
end
|
56
53
|
|
57
54
|
# A port was not specified, therefore we attempt to detect the best port to use
|
@@ -103,12 +100,9 @@ module Guard
|
|
103
100
|
# @option options [String] rackup_config custom rackup config to use (i.e. spec/dummy/config.ru for mountable engines)
|
104
101
|
#
|
105
102
|
def start_rack_server(server, port, options)
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
Compat::UI.info "Guard::Jasmine starts #{ server } spec server on port #{ port } in #{ environment } environment (coverage #{ coverage })."
|
111
|
-
execute(options, ['rackup', '-E', environment.to_s, '-p', port.to_s, '-s', server.to_s, rackup_config])
|
103
|
+
coverage = options[:coverage] ? 'on' : 'off'
|
104
|
+
Compat::UI.info "Guard::Jasmine starts #{server} spec server on port #{port} in #{options[:server_env]} environment (coverage #{coverage})."
|
105
|
+
execute(options, ['rackup', '-E', options[:server_env].to_s, '-p', port.to_s, '-s', server.to_s, options[:rackup_config]])
|
112
106
|
end
|
113
107
|
|
114
108
|
# Start the Rack server of the current project. This
|
@@ -120,11 +114,9 @@ module Guard
|
|
120
114
|
# @option options [Number] port the server port
|
121
115
|
#
|
122
116
|
def start_unicorn_server(port, options)
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
Compat::UI.info "Guard::Jasmine starts Unicorn spec server on port #{ port } in #{ environment } environment (coverage #{ coverage })."
|
127
|
-
execute(options, ['unicorn_rails', '-E', environment.to_s, '-p', port.to_s])
|
117
|
+
coverage = options[:coverage] ? 'on' : 'off'
|
118
|
+
Compat::UI.info "Guard::Jasmine starts Unicorn spec server on port #{port} in #{options[:server_env]} environment (coverage #{coverage})."
|
119
|
+
execute(options, ['unicorn_rails', '-E', options[:server_env].to_s, '-p', port.to_s])
|
128
120
|
end
|
129
121
|
|
130
122
|
# Start the Jasmine gem server of the current project.
|
@@ -134,8 +126,8 @@ module Guard
|
|
134
126
|
# @option options [Symbol] server the rack server to use
|
135
127
|
#
|
136
128
|
def start_rake_server(port, task, options)
|
137
|
-
Compat::UI.info "Guard::Jasmine starts Jasmine Gem test server on port #{
|
138
|
-
execute(options, ['rake', task, "JASMINE_PORT=#{
|
129
|
+
Compat::UI.info "Guard::Jasmine starts Jasmine Gem test server on port #{port}."
|
130
|
+
execute(options, ['rake', task, "JASMINE_PORT=#{port}"])
|
139
131
|
end
|
140
132
|
|
141
133
|
# Builds a child process with the given command and arguments
|
@@ -147,17 +139,15 @@ module Guard
|
|
147
139
|
cmd.unshift("ruby", "-S")
|
148
140
|
end
|
149
141
|
self.cmd = cmd
|
150
|
-
if options[:debug]
|
151
|
-
puts "Starting server using: #{cmd.join(' ')}"
|
152
|
-
end
|
142
|
+
puts "Starting server using: #{cmd.join(' ')}" if options[:debug]
|
153
143
|
self.process = ChildProcess.build(*cmd.compact)
|
154
144
|
process.environment['COVERAGE'] = options[:coverage].to_s
|
155
145
|
process.environment['IGNORE_INSTRUMENTATION'] = options[:ignore_instrumentation].to_s
|
156
146
|
process.io.inherit! if options[:verbose]
|
157
147
|
process.start
|
158
148
|
rescue => e
|
159
|
-
Compat::UI.error "Cannot start server using command #{
|
160
|
-
Compat::UI.error "Error was: #{
|
149
|
+
Compat::UI.error "Cannot start server using command #{cmd.join(' ')}."
|
150
|
+
Compat::UI.error "Error was: #{e.message}"
|
161
151
|
end
|
162
152
|
|
163
153
|
# Wait until the Jasmine test server is running.
|
data/lib/guard/jasmine/task.rb
CHANGED
@@ -2,5 +2,5 @@ guard :jasmine do
|
|
2
2
|
watch(%r{spec/javascripts/spec\.(js\.coffee|js|coffee)$}) { 'spec/javascripts' }
|
3
3
|
watch(%r{spec/javascripts/.+_spec\.(js\.coffee|js|coffee)$})
|
4
4
|
watch(%r{spec/javascripts/fixtures/.+$})
|
5
|
-
watch(%r{app/assets/javascripts/(.+?)\.(js\.coffee|js|coffee)(?:\.\w+)*$}) { |m| "spec/javascripts/#{
|
5
|
+
watch(%r{app/assets/javascripts/(.+?)\.(js\.coffee|js|coffee)(?:\.\w+)*$}) { |m| "spec/javascripts/#{m[1]}_spec.#{m[2]}" }
|
6
6
|
end
|
data/lib/guard/jasmine/util.rb
CHANGED
@@ -21,7 +21,7 @@ module Guard
|
|
21
21
|
url = URI.parse(options[:jasmine_url])
|
22
22
|
|
23
23
|
begin
|
24
|
-
::Guard::Jasmine::Formatter.info "Waiting for Jasmine test runner at #{
|
24
|
+
::Guard::Jasmine::Formatter.info "Waiting for Jasmine test runner at #{url}"
|
25
25
|
|
26
26
|
http = Net::HTTP.new(url.host, url.port)
|
27
27
|
http.read_timeout = options[:server_timeout]
|
@@ -30,7 +30,7 @@ module Guard
|
|
30
30
|
available = response.code.to_i == 200
|
31
31
|
|
32
32
|
unless available
|
33
|
-
::Guard::Jasmine::Formatter.error "Jasmine test runner failed with status #{
|
33
|
+
::Guard::Jasmine::Formatter.error "Jasmine test runner failed with status #{response.code}"
|
34
34
|
if response.body
|
35
35
|
::Guard::Jasmine::Formatter.error 'Please open the Jasmine runner in your browser for more information.'
|
36
36
|
end
|
@@ -44,7 +44,7 @@ module Guard
|
|
44
44
|
false
|
45
45
|
|
46
46
|
rescue => e
|
47
|
-
::Guard::Jasmine::Formatter.error "Jasmine test runner isn't available: #{
|
47
|
+
::Guard::Jasmine::Formatter.error "Jasmine test runner isn't available: #{e.message}"
|
48
48
|
false
|
49
49
|
end
|
50
50
|
end
|
@@ -65,15 +65,15 @@ module Guard
|
|
65
65
|
|
66
66
|
if cleaned_version
|
67
67
|
if Gem::Version.new(cleaned_version[0]) < Gem::Version.new('1.3.0')
|
68
|
-
::Guard::Jasmine::Formatter.error "PhantomJS executable at #{
|
68
|
+
::Guard::Jasmine::Formatter.error "PhantomJS executable at #{bin} must be at least version 1.3.0"
|
69
69
|
else
|
70
70
|
true
|
71
71
|
end
|
72
72
|
else
|
73
|
-
::Guard::Jasmine::Formatter.error "PhantomJS reports unknown version format: #{
|
73
|
+
::Guard::Jasmine::Formatter.error "PhantomJS reports unknown version format: #{version}"
|
74
74
|
end
|
75
75
|
else
|
76
|
-
::Guard::Jasmine::Formatter.error "PhantomJS executable doesn't exist at #{
|
76
|
+
::Guard::Jasmine::Formatter.error "PhantomJS executable doesn't exist at #{bin}"
|
77
77
|
end
|
78
78
|
else
|
79
79
|
::Guard::Jasmine::Formatter.error 'PhantomJS executable couldn\'t be auto detected.'
|
@@ -102,7 +102,7 @@ module Guard
|
|
102
102
|
|
103
103
|
ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
|
104
104
|
exts.each do |ext|
|
105
|
-
exe = "#{
|
105
|
+
exe = "#{path}/#{cmd}#{ext}"
|
106
106
|
return exe if File.file?(exe) && File.executable?(exe)
|
107
107
|
end
|
108
108
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: guard-jasmine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Kessler
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2016-08-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: guard
|
@@ -17,14 +17,14 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: '2.
|
20
|
+
version: '2.14'
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: '2.
|
27
|
+
version: '2.14'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: guard-compat
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -45,28 +45,28 @@ dependencies:
|
|
45
45
|
requirements:
|
46
46
|
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: '2.
|
48
|
+
version: '2.4'
|
49
49
|
type: :runtime
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
53
|
- - "~>"
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: '2.
|
55
|
+
version: '2.4'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: multi_json
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
60
|
- - "~>"
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version: '1.
|
62
|
+
version: '1.12'
|
63
63
|
type: :runtime
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
67
|
- - "~>"
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version: '1.
|
69
|
+
version: '1.12'
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: childprocess
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
@@ -175,9 +175,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
175
175
|
version: 1.3.6
|
176
176
|
requirements: []
|
177
177
|
rubyforge_project: guard-jasmine
|
178
|
-
rubygems_version: 2.
|
178
|
+
rubygems_version: 2.5.1
|
179
179
|
signing_key:
|
180
180
|
specification_version: 4
|
181
181
|
summary: Guard gem for headless testing with Jasmine
|
182
182
|
test_files: []
|
183
|
-
has_rdoc:
|