guard-jasmine 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,15 +7,13 @@ require 'jasmine'
7
7
 
8
8
  module Guard
9
9
  class Jasmine
10
-
11
10
  # Start and stop a Jasmine test server for requesting the specs
12
11
  # from PhantomJS.
13
12
  #
14
13
  module Server
15
14
  class << self
16
-
17
15
  attr_accessor :process
18
-
16
+ attr_accessor :cmd
19
17
  # Start the internal test server for getting the Jasmine runner.
20
18
  #
21
19
  # @param [Hash] options the server options
@@ -32,14 +30,14 @@ module Guard
32
30
  timeout = options[:server_timeout]
33
31
 
34
32
  case server
35
- when :webrick, :mongrel, :thin, :puma
36
- start_rack_server(server, port, options)
37
- when :unicorn
38
- start_unicorn_server(port, options)
39
- when :jasmine_gem
40
- start_rake_server(port, 'jasmine', options)
41
- else
42
- start_rake_server(port, server.to_s, options) unless server == :none
33
+ when :webrick, :mongrel, :thin, :puma
34
+ start_rack_server(server, port, options)
35
+ when :unicorn
36
+ start_unicorn_server(port, options)
37
+ when :jasmine_gem
38
+ start_rake_server(port, 'jasmine', options)
39
+ else
40
+ start_rake_server(port, server.to_s, options) unless server == :none
43
41
  end
44
42
 
45
43
  wait_for_server(port, timeout) unless server == :none
@@ -48,9 +46,9 @@ module Guard
48
46
  # Stop the server thread.
49
47
  #
50
48
  def stop
51
- if self.process
49
+ if process
52
50
  ::Guard::UI.info 'Guard::Jasmine stops server.'
53
- self.process.stop(5)
51
+ process.stop(5)
54
52
  end
55
53
  end
56
54
 
@@ -72,9 +70,9 @@ module Guard
72
70
  # @return [Symbol] the server strategy
73
71
  #
74
72
  def detect_server(spec_dir)
75
- if spec_dir && File.exists?(File.join(spec_dir, 'support','jasmine.yml'))
73
+ if spec_dir && File.exist?(File.join(spec_dir, 'support', 'jasmine.yml'))
76
74
  :jasmine_gem
77
- elsif File.exists?('config.ru')
75
+ elsif File.exist?('config.ru')
78
76
  %w(unicorn thin mongrel puma).each do |server|
79
77
  begin
80
78
  require server
@@ -108,15 +106,7 @@ module Guard
108
106
  coverage = options[:coverage] ? 'on' : 'off'
109
107
 
110
108
  ::Guard::UI.info "Guard::Jasmine starts #{ server } spec server on port #{ port } in #{ environment } environment (coverage #{ coverage })."
111
-
112
- self.process = ChildProcess.build(*['rackup', '-E', environment.to_s, '-p', port.to_s, '-s', server.to_s, rackup_config].compact)
113
- self.process.environment['COVERAGE'] = options[:coverage].to_s
114
- self.process.environment['IGNORE_INSTRUMENTATION'] = options[:ignore_instrumentation].to_s
115
- self.process.io.inherit! if options[:verbose]
116
- self.process.start
117
-
118
- rescue => e
119
- ::Guard::UI.error "Cannot start Rack server: #{ e.message }"
109
+ execute(options, ['rackup', '-E', environment.to_s, '-p', port.to_s, '-s', server.to_s, rackup_config])
120
110
  end
121
111
 
122
112
  # Start the Rack server of the current project. This
@@ -132,14 +122,7 @@ module Guard
132
122
  coverage = options[:coverage] ? 'on' : 'off'
133
123
 
134
124
  ::Guard::UI.info "Guard::Jasmine starts Unicorn spec server on port #{ port } in #{ environment } environment (coverage #{ coverage })."
135
-
136
- self.process = ChildProcess.build('unicorn_rails', '-E', environment.to_s, '-p', port.to_s)
137
- self.process.environment['COVERAGE'] = options[:coverage].to_s
138
- self.process.io.inherit! if options[:verbose]
139
- self.process.start
140
-
141
- rescue => e
142
- ::Guard::UI.error "Cannot start Unicorn server: #{ e.message }"
125
+ execute(options, ['unicorn_rails', '-E', environment.to_s, '-p', port.to_s])
143
126
  end
144
127
 
145
128
  # Start the Jasmine gem server of the current project.
@@ -149,15 +132,27 @@ module Guard
149
132
  # @option options [Symbol] server the rack server to use
150
133
  #
151
134
  def start_rake_server(port, task, options)
152
-
153
135
  ::Guard::UI.info "Guard::Jasmine starts Jasmine Gem test server on port #{ port }."
136
+ execute(options, ['rake', task, "JASMINE_PORT=#{ port }"])
137
+ end
154
138
 
155
- self.process = ChildProcess.build('ruby', '-S', 'rake', task, "JASMINE_PORT=#{ port }")
156
- self.process.io.inherit! if options[:verbose]
157
- self.process.start
158
-
139
+ # Builds a child process with the given command and arguments
140
+ # @param [Array<string>] array of arguments to send to ChildProcess
141
+ def execute(options, cmd)
142
+ if RUBY_PLATFORM == "java"
143
+ cmd.unshift("jruby", "-S")
144
+ else
145
+ cmd.unshift("ruby", "-S")
146
+ end
147
+ self.cmd = cmd
148
+ self.process = ChildProcess.build(*cmd.compact)
149
+ process.environment['COVERAGE'] = options[:coverage].to_s
150
+ process.environment['IGNORE_INSTRUMENTATION'] = options[:ignore_instrumentation].to_s
151
+ process.io.inherit! if options[:verbose]
152
+ process.start
159
153
  rescue => e
160
- ::Guard::UI.error "Cannot start Rake task server: #{ e.message }"
154
+ ::Guard::UI.error "Cannot start server using command #{ cmd.join(' ') }."
155
+ ::Guard::UI.error "Error was: #{ e.message }"
161
156
  end
162
157
 
163
158
  # Wait until the Jasmine test server is running.
@@ -166,8 +161,8 @@ module Guard
166
161
  # @param [Number] timeout the server wait timeout
167
162
  #
168
163
  def wait_for_server(port, timeout)
169
- Timeout::timeout(timeout) do
170
- while true
164
+ Timeout.timeout(timeout) do
165
+ loop do
171
166
  begin
172
167
  ::TCPSocket.new('127.0.0.1', port).close
173
168
  break
@@ -179,12 +174,16 @@ module Guard
179
174
  end
180
175
 
181
176
  rescue Timeout::Error
182
- ::Guard::UI.warning 'Timeout while waiting for the server startup. You may need to increase the `:server_timeout` option.'
177
+ ::Guard::UI.warning "Timeout while waiting for the server to startup"
178
+ ::Guard::UI.warning "Most likely there is a configuration error that's preventing the server from starting"
179
+ ::Guard::UI.warning "You may need to increase the `:server_timeout` option."
180
+ ::Guard::UI.warning "The commandline that was used to start the server was:"
181
+ ::Guard::UI.warning cmd.join(' ')
182
+ ::Guard::UI.warning "You should attempt to run that and see if any errors occur"
183
+
183
184
  throw :task_has_failed
184
185
  end
185
-
186
186
  end
187
187
  end
188
-
189
188
  end
190
189
  end
@@ -6,12 +6,10 @@ require 'rake/tasklib'
6
6
  require 'guard/jasmine/cli'
7
7
 
8
8
  module Guard
9
-
10
9
  # Provides a method to define a Rake task that
11
10
  # runs the Jasmine specs.
12
11
  #
13
12
  class JasmineTask < ::Rake::TaskLib
14
-
15
13
  # Name of the main, top level task
16
14
  attr_accessor :name
17
15
 
@@ -39,14 +37,13 @@ module Guard
39
37
  rescue SystemExit => e
40
38
  case e.status
41
39
  when 1
42
- fail 'Some specs have failed'
40
+ raise 'Some specs have failed'
43
41
  when 2
44
- fail "The spec couldn't be run: #{ e.message }'"
42
+ raise "The spec couldn't be run: #{ e.message }'"
45
43
  end
46
44
  end
47
45
  end
48
46
  end
49
47
  end
50
-
51
48
  end
52
49
  end
@@ -4,11 +4,9 @@ require 'guard/jasmine/formatter'
4
4
 
5
5
  module Guard
6
6
  class Jasmine
7
-
8
7
  # Provider of some shared utility methods.
9
8
  #
10
9
  module Util
11
-
12
10
  # Verifies if the Jasmine test runner is available.
13
11
  # If the runner is not available within 15 seconds, then
14
12
  # the availability check will cancel.
@@ -40,7 +38,7 @@ module Guard
40
38
  available
41
39
  end
42
40
 
43
- rescue Timeout::Error => e
41
+ rescue Timeout::Error
44
42
  ::Guard::Jasmine::Formatter.error 'Timeout waiting for the Jasmine test runner.'
45
43
  false
46
44
 
@@ -110,8 +108,6 @@ module Guard
110
108
 
111
109
  nil
112
110
  end
113
-
114
111
  end
115
-
116
112
  end
117
113
  end
@@ -1,6 +1,6 @@
1
1
  module Guard
2
2
  module JasmineVersion
3
3
  # Guard::Jasmine version that is used for the Gem specification
4
- VERSION = '2.0.0'
4
+ VERSION = '2.0.1'
5
5
  end
6
6
  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.0
4
+ version: 2.0.1
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: 2014-12-06 00:00:00.000000000 Z
12
+ date: 2014-12-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: guard
@@ -25,6 +25,20 @@ dependencies:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
27
  version: '2.8'
28
+ - !ruby/object:Gem::Dependency
29
+ name: guard-compat
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '0.3'
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '0.3'
28
42
  - !ruby/object:Gem::Dependency
29
43
  name: jasmine
30
44
  requirement: !ruby/object:Gem::Requirement
@@ -137,62 +151,6 @@ dependencies:
137
151
  - - ">="
138
152
  - !ruby/object:Gem::Version
139
153
  version: '0'
140
- - !ruby/object:Gem::Dependency
141
- name: guard-coffeescript
142
- requirement: !ruby/object:Gem::Requirement
143
- requirements:
144
- - - ">="
145
- - !ruby/object:Gem::Version
146
- version: '0'
147
- type: :development
148
- prerelease: false
149
- version_requirements: !ruby/object:Gem::Requirement
150
- requirements:
151
- - - ">="
152
- - !ruby/object:Gem::Version
153
- version: '0'
154
- - !ruby/object:Gem::Dependency
155
- name: guard-shell
156
- requirement: !ruby/object:Gem::Requirement
157
- requirements:
158
- - - ">="
159
- - !ruby/object:Gem::Version
160
- version: '0'
161
- type: :development
162
- prerelease: false
163
- version_requirements: !ruby/object:Gem::Requirement
164
- requirements:
165
- - - ">="
166
- - !ruby/object:Gem::Version
167
- version: '0'
168
- - !ruby/object:Gem::Dependency
169
- name: guard-rspec
170
- requirement: !ruby/object:Gem::Requirement
171
- requirements:
172
- - - ">="
173
- - !ruby/object:Gem::Version
174
- version: '0'
175
- type: :development
176
- prerelease: false
177
- version_requirements: !ruby/object:Gem::Requirement
178
- requirements:
179
- - - ">="
180
- - !ruby/object:Gem::Version
181
- version: '0'
182
- - !ruby/object:Gem::Dependency
183
- name: rspec
184
- requirement: !ruby/object:Gem::Requirement
185
- requirements:
186
- - - "~>"
187
- - !ruby/object:Gem::Version
188
- version: '3'
189
- type: :development
190
- prerelease: false
191
- version_requirements: !ruby/object:Gem::Requirement
192
- requirements:
193
- - - "~>"
194
- - !ruby/object:Gem::Version
195
- version: '3'
196
154
  - !ruby/object:Gem::Dependency
197
155
  name: yard
198
156
  requirement: !ruby/object:Gem::Requirement