guard-jasmine 0.8.3 → 0.8.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +4 -1
- data/lib/guard/jasmine.rb +3 -1
- data/lib/guard/jasmine/phantomjs/run-jasmine.coffee +3 -1
- data/lib/guard/jasmine/runner.rb +7 -3
- data/lib/guard/jasmine/server.rb +8 -6
- data/lib/guard/jasmine/version.rb +1 -1
- metadata +23 -23
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Guard::Jasmine automatically tests your Jasmine specs on Rails when files are modified.
|
4
4
|
|
5
|
-
Tested on MRI Ruby 1.8.7, 1.9.2, 1.9.3, REE
|
5
|
+
Tested on MRI Ruby 1.8.7, 1.9.2, 1.9.3, REE 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).
|
@@ -215,6 +215,9 @@ The general options configures the environment that is needed to run Guard::Jasm
|
|
215
215
|
:server => :jasmine_gem # Jasmine server to use, either :auto, :rack, :jasmine_gem or :none
|
216
216
|
# default: :auto
|
217
217
|
|
218
|
+
:server_env => :development # Jasmine server Rails environment to set, e.g. :development or :test
|
219
|
+
# default: :test
|
220
|
+
|
218
221
|
:port => 9292 # Jasmine server port to use.
|
219
222
|
# default: 8888
|
220
223
|
|
data/lib/guard/jasmine.rb
CHANGED
@@ -20,6 +20,7 @@ module Guard
|
|
20
20
|
|
21
21
|
DEFAULT_OPTIONS = {
|
22
22
|
:server => :auto,
|
23
|
+
:server_env => 'test',
|
23
24
|
:port => 8888,
|
24
25
|
:jasmine_url => 'http://localhost:8888/jasmine',
|
25
26
|
:timeout => 10000,
|
@@ -39,6 +40,7 @@ module Guard
|
|
39
40
|
# @param [Array<Guard::Watcher>] watchers the watchers in the Guard block
|
40
41
|
# @param [Hash] options the options for the Guard
|
41
42
|
# @option options [String] :server the server to use, either :rails or :jasmine
|
43
|
+
# @option options [String] :server_env the server environment to use, for example :development, :test
|
42
44
|
# @option options [String] :port the port for the Jasmine test server
|
43
45
|
# @option options [String] :jasmine_url the url of the Jasmine test runner
|
44
46
|
# @option options [String] :phantomjs_bin the location of the PhantomJS binary
|
@@ -73,7 +75,7 @@ module Guard
|
|
73
75
|
def start
|
74
76
|
if phantomjs_bin_valid?(options[:phantomjs_bin])
|
75
77
|
|
76
|
-
Server.start(options[:server], options[:port]) unless options[:server] == :none
|
78
|
+
Server.start(options[:server], options[:port], options[:server_env]) unless options[:server] == :none
|
77
79
|
|
78
80
|
if jasmine_runner_available?(options[:jasmine_url])
|
79
81
|
run_all if options[:all_on_start]
|
@@ -38,7 +38,7 @@ waitFor = (test, ready, timeout = 5000) ->
|
|
38
38
|
# Test if the specs have finished.
|
39
39
|
#
|
40
40
|
specsReady = ->
|
41
|
-
page.evaluate ->
|
41
|
+
page.evaluate -> window.resultReceived
|
42
42
|
|
43
43
|
#
|
44
44
|
# SCRIPT START
|
@@ -84,6 +84,7 @@ page.onConsoleMessage = (msg, line, source) ->
|
|
84
84
|
page.addLogs(suite)
|
85
85
|
|
86
86
|
console.log JSON.stringify(result, undefined, 2)
|
87
|
+
page.evaluate -> window.resultReceived = true
|
87
88
|
|
88
89
|
else if /^SPEC_START: (\d+)$/.test(msg)
|
89
90
|
currentSpecId = Number(RegExp.$1)
|
@@ -227,6 +228,7 @@ page.onInitialized = ->
|
|
227
228
|
# Attach the console reporter when the document is ready.
|
228
229
|
#
|
229
230
|
window.onload = ->
|
231
|
+
window.resultReceived = false
|
230
232
|
jasmine.getEnv().addReporter(new ConsoleReporter())
|
231
233
|
|
232
234
|
# Open web page and run the Jasmine test runner
|
data/lib/guard/jasmine/runner.rb
CHANGED
@@ -164,9 +164,13 @@ module Guard
|
|
164
164
|
result
|
165
165
|
|
166
166
|
rescue Exception => e
|
167
|
-
|
168
|
-
|
169
|
-
|
167
|
+
if json == ''
|
168
|
+
Formatter.error("No response from the Jasmine runner!")
|
169
|
+
else
|
170
|
+
Formatter.error("Cannot decode JSON from PhantomJS runner: #{ e.message }")
|
171
|
+
Formatter.error('Please report an issue at: https://github.com/netzpirat/guard-jasmine/issues')
|
172
|
+
Formatter.error("JSON response: #{ json }")
|
173
|
+
end
|
170
174
|
ensure
|
171
175
|
output.close
|
172
176
|
end
|
data/lib/guard/jasmine/server.rb
CHANGED
@@ -15,13 +15,14 @@ module Guard
|
|
15
15
|
#
|
16
16
|
# @param [String] strategy the server strategy to use
|
17
17
|
# @param [Number] port the server port
|
18
|
+
# @param [String] environment the Rails environment
|
18
19
|
#
|
19
|
-
def start(strategy, port)
|
20
|
+
def start(strategy, port, environment)
|
20
21
|
strategy = detect_server if strategy == :auto
|
21
22
|
|
22
23
|
case strategy
|
23
24
|
when :rack
|
24
|
-
start_rack_server(port)
|
25
|
+
start_rack_server(port, environment)
|
25
26
|
when :jasmine_gem
|
26
27
|
start_jasmine_gem_server(port)
|
27
28
|
end
|
@@ -42,15 +43,16 @@ module Guard
|
|
42
43
|
# in the current directory.
|
43
44
|
#
|
44
45
|
# @param [Number] port the server port
|
46
|
+
# @param [String] environment the Rails environment
|
45
47
|
#
|
46
|
-
def start_rack_server(port)
|
48
|
+
def start_rack_server(port, environment)
|
47
49
|
require 'rack'
|
48
50
|
|
49
|
-
::Guard::UI.info "Guard::Jasmine starts Rack test server on port #{ port }."
|
51
|
+
::Guard::UI.info "Guard::Jasmine starts Rack test server on port #{ port } in #{ environment } environment."
|
50
52
|
|
51
53
|
self.thread = Thread.new {
|
52
|
-
ENV['RAILS_ENV'] =
|
53
|
-
Rack::Server.start(:config => 'config.ru', :Port => port, :AccessLog => []
|
54
|
+
ENV['RAILS_ENV'] = environment.to_s
|
55
|
+
Rack::Server.start(:config => 'config.ru', :Port => port, :AccessLog => [])
|
54
56
|
}
|
55
57
|
|
56
58
|
rescue Exception => e
|
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: 0.8.
|
4
|
+
version: 0.8.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2011-11-22 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: guard
|
16
|
-
requirement: &
|
16
|
+
requirement: &70096761369580 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 0.8.3
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70096761369580
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: multi_json
|
27
|
-
requirement: &
|
27
|
+
requirement: &70096761368900 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 1.0.3
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70096761368900
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: version
|
38
|
-
requirement: &
|
38
|
+
requirement: &70096761368140 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 1.0.0
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70096761368140
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: thor
|
49
|
-
requirement: &
|
49
|
+
requirement: &70096761366940 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 0.14.6
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70096761366940
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rack
|
60
|
-
requirement: &
|
60
|
+
requirement: &70096761366300 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: 1.3.5
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70096761366300
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: bundler
|
71
|
-
requirement: &
|
71
|
+
requirement: &70096761365220 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ~>
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '1.0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70096761365220
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: guard-rspec
|
82
|
-
requirement: &
|
82
|
+
requirement: &70096761364340 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ~>
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: '0.5'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *70096761364340
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: rspec
|
93
|
-
requirement: &
|
93
|
+
requirement: &70096761363720 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ~>
|
@@ -98,10 +98,10 @@ dependencies:
|
|
98
98
|
version: '2.7'
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *70096761363720
|
102
102
|
- !ruby/object:Gem::Dependency
|
103
103
|
name: yard
|
104
|
-
requirement: &
|
104
|
+
requirement: &70096761362980 !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
107
|
- - ~>
|
@@ -109,10 +109,10 @@ dependencies:
|
|
109
109
|
version: 0.7.3
|
110
110
|
type: :development
|
111
111
|
prerelease: false
|
112
|
-
version_requirements: *
|
112
|
+
version_requirements: *70096761362980
|
113
113
|
- !ruby/object:Gem::Dependency
|
114
114
|
name: redcarpet
|
115
|
-
requirement: &
|
115
|
+
requirement: &70096761361980 !ruby/object:Gem::Requirement
|
116
116
|
none: false
|
117
117
|
requirements:
|
118
118
|
- - ~>
|
@@ -120,10 +120,10 @@ dependencies:
|
|
120
120
|
version: 1.17.2
|
121
121
|
type: :development
|
122
122
|
prerelease: false
|
123
|
-
version_requirements: *
|
123
|
+
version_requirements: *70096761361980
|
124
124
|
- !ruby/object:Gem::Dependency
|
125
125
|
name: pry
|
126
|
-
requirement: &
|
126
|
+
requirement: &70096761361200 !ruby/object:Gem::Requirement
|
127
127
|
none: false
|
128
128
|
requirements:
|
129
129
|
- - ~>
|
@@ -131,7 +131,7 @@ dependencies:
|
|
131
131
|
version: 0.9.6.2
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
|
-
version_requirements: *
|
134
|
+
version_requirements: *70096761361200
|
135
135
|
description: Guard::Jasmine automatically tests your Jasmine specs on PhantomJS
|
136
136
|
email:
|
137
137
|
- michi@netzpiraten.ch
|