guard-jasmine 1.9.4 → 1.10.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -353,8 +353,8 @@ The server options configures the server environment that is needed to run Guard
353
353
  :server_timeout => 30 # The number of seconds to wait for the Jasmine spec server
354
354
  # default: 15
355
355
 
356
- :port => 9292 # Jasmine server port to use.
357
- # default: 8888
356
+ :port => 8888 # Jasmine server port to use.
357
+ # default: a random, free server port
358
358
 
359
359
  :phantomjs_bin => '~/bin/phantomjs' # Path to phantomjs.
360
360
  # default: auto-detect 'phantomjs'
@@ -24,7 +24,7 @@ module Guard
24
24
  :server => :auto,
25
25
  :server_env => ENV['RAILS_ENV'] || 'development',
26
26
  :server_timeout => 15,
27
- :port => 8888,
27
+ :port => nil,
28
28
  :rackup_config => nil,
29
29
  :jasmine_url => 'http://localhost:8888/jasmine',
30
30
  :timeout => 10,
@@ -28,14 +28,14 @@ module Guard
28
28
  def start(options)
29
29
  server = options[:server]
30
30
  server = detect_server(options[:spec_dir]) if server == :auto
31
- port = options[:port]
31
+ port = options[:port] || detect_server_port
32
32
  timeout = options[:server_timeout]
33
33
 
34
34
  case server
35
35
  when :webrick, :mongrel, :thin
36
- start_rack_server(server, options)
36
+ start_rack_server(server, port, options)
37
37
  when :unicorn
38
- start_unicorn_server(options)
38
+ start_unicorn_server(port, options)
39
39
  when :jasmine_gem
40
40
  start_rake_server(port, 'jasmine')
41
41
  else
@@ -61,15 +61,14 @@ module Guard
61
61
  # in the current directory.
62
62
  #
63
63
  # @param [Symbol] server the server name
64
+ # @param [Integer] port the server port
64
65
  # @param [Hash] options the server options
65
66
  # @option options [Symbol] server the rack server to use
66
67
  # @option options [String] server_env the Rails environment
67
- # @option options [Number] port the server port
68
68
  # @option options [String] rackup_config custom rackup config to use (i.e. spec/dummy/config.ru for mountable engines)
69
69
  #
70
- def start_rack_server(server, options)
70
+ def start_rack_server(server, port, options)
71
71
  environment = options[:server_env]
72
- port = options[:port]
73
72
  rackup_config = options[:rackup_config]
74
73
 
75
74
  ::Guard::UI.info "Guard::Jasmine starts #{ server } test server on port #{ port } in #{ environment } environment."
@@ -90,9 +89,8 @@ module Guard
90
89
  # @option options [String] server_env the Rails environment
91
90
  # @option options [Number] port the server port
92
91
  #
93
- def start_unicorn_server(options)
92
+ def start_unicorn_server(port, options)
94
93
  environment = options[:server_env]
95
- port = options[:port]
96
94
 
97
95
  ::Guard::UI.info "Guard::Jasmine starts Unicorn test server on port #{ port } in #{ environment } environment."
98
96
 
@@ -103,7 +101,7 @@ module Guard
103
101
  rescue => e
104
102
  ::Guard::UI.error "Cannot start Unicorn server: #{ e.message }"
105
103
  end
106
-
104
+
107
105
  # Start the Jasmine gem server of the current project.
108
106
  #
109
107
  # @param [Number] port the server port
@@ -143,6 +141,20 @@ module Guard
143
141
  end
144
142
  end
145
143
 
144
+ # Detect the server port to use
145
+ #
146
+ # @return [Integer] a free server port
147
+ #
148
+ def detect_server_port
149
+ server = TCPServer.new('127.0.0.1', 0)
150
+ port = server.addr[1]
151
+ server.close
152
+
153
+ port
154
+ rescue Errno::EADDRINUSE
155
+ retry
156
+ end
157
+
146
158
  # Wait until the Jasmine test server is running.
147
159
  #
148
160
  # @param [Number] port the server port
@@ -160,7 +172,7 @@ module Guard
160
172
  sleep 0.1
161
173
  end
162
174
  end
163
-
175
+
164
176
  rescue Timeout::Error
165
177
  ::Guard::UI.warning 'Timeout while waiting for the server startup. You may need to increase the `:server_timeout` option.'
166
178
  throw :task_has_failed
@@ -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 = '1.9.4'
4
+ VERSION = '1.10.0'
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: 1.9.4
4
+ version: 1.10.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-11 00:00:00.000000000 Z
12
+ date: 2012-11-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: guard