guard-jasmine 1.10.0 → 1.10.1

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.
data/README.md CHANGED
@@ -368,15 +368,14 @@ The server options configures the server environment that is needed to run Guard
368
368
  # and the config.ru is within the dummy app
369
369
  ```
370
370
 
371
- If you're setting the `:server` option to `:none`, you can supply the Jasmine runner url manually:
371
+ If you're setting the `:server` option to `:none` or need to access your specs on a other host than `localhost`, you can
372
+ supply the Jasmine runner url manually:
372
373
 
373
374
  ```ruby
374
- :jasmine_url => 'http://192.168.1.5/jasmine' # URL where Jasmine is served.
375
- # default: http://127.0.0.1:8888/jasmine
375
+ :jasmine_url => 'http://192.168.1.5:1234/jasmine' # URL where Jasmine is served.
376
+ # default: nil
376
377
  ```
377
-
378
- Detecting the server with the `auto` option does only detect the jasmine gem or webrick. If you want to use mongrel or
379
- thins, you have to set it explicit in the server option.
378
+ You may want to have also a fixed port instead of the random generated one.
380
379
 
381
380
  The reason why the Server environment is set to `development` by default is that in development mode
382
381
  the asset pipeline doesn't concatenate the JavaScripts and you'll see the line number in the real file,
@@ -543,7 +542,7 @@ Options:
543
542
  # `unicorn`, `jasmine_gem` or `none`
544
543
  # Default: auto
545
544
  -p, [--port=N] # Server port to use
546
- # Default: 3001
545
+ # Default: Random free port
547
546
  -e, [--server-env=SERVER_ENV] # The server environment to use, for example `development`, `test` etc.
548
547
  # Default: test
549
548
  [--server-timeout=N] # The number of seconds to wait for the Jasmine spec server
@@ -552,7 +551,7 @@ Options:
552
551
  -d, [--spec-dir=SPEC_DIR] # The directory with the Jasmine specs
553
552
  # Default: spec/javascripts
554
553
  -u, [--url=URL] # The url of the Jasmine test runner_options
555
- # Default: http://localhost:3001/jasmine
554
+ # Default: nil
556
555
  -t, [--timeout=N] # The maximum time in milliseconds to wait for the spec
557
556
  # runner to finish
558
557
  # Default: 10000
data/lib/guard/jasmine.rb CHANGED
@@ -26,7 +26,7 @@ module Guard
26
26
  :server_timeout => 15,
27
27
  :port => nil,
28
28
  :rackup_config => nil,
29
- :jasmine_url => 'http://localhost:8888/jasmine',
29
+ :jasmine_url => nil,
30
30
  :timeout => 10,
31
31
  :spec_dir => 'spec/javascripts',
32
32
  :notification => true,
@@ -69,7 +69,8 @@ module Guard
69
69
  # @option options [Hash] :run_all options overwrite options when run all specs
70
70
  #
71
71
  def initialize(watchers = [], options = { })
72
- options[:jasmine_url] = "http://localhost:#{ options[:port] }/jasmine" if options[:port] && !options[:jasmine_url]
72
+ options[:port] ||= Jasmine.find_free_server_port
73
+ options[:jasmine_url] = "http://localhost:#{ options[:port] }/jasmine" unless options[:jasmine_url]
73
74
  options = DEFAULT_OPTIONS.merge(options)
74
75
  options[:specdoc] = :failure if ![:always, :never, :failure].include? options[:specdoc]
75
76
  options[:server] ||= :auto
@@ -31,7 +31,6 @@ module Guard
31
31
  method_option :port,
32
32
  :type => :numeric,
33
33
  :aliases => '-p',
34
- :default => 3001,
35
34
  :desc => 'Server port to use'
36
35
 
37
36
  method_option :server_env,
@@ -64,7 +63,6 @@ module Guard
64
63
  method_option :url,
65
64
  :type => :string,
66
65
  :aliases => '-u',
67
- :default => 'http://localhost:3001/jasmine',
68
66
  :desc => 'The url of the Jasmine test runner'
69
67
 
70
68
  method_option :timeout,
@@ -103,10 +101,10 @@ module Guard
103
101
  paths = [options.spec_dir] if paths.empty?
104
102
 
105
103
  runner_options = {}
106
- runner_options[:jasmine_url] = options.url
104
+ runner_options[:port] = options.port || CLI.find_free_server_port
105
+ runner_options[:jasmine_url] = options.url || "http://localhost:#{ runner_options[:port] }/jasmine"
107
106
  runner_options[:phantomjs_bin] = options.bin || CLI.which('phantomjs')
108
107
  runner_options[:timeout] = options.timeout
109
- runner_options[:port] = options.port
110
108
  runner_options[:server_env] = options.server_env
111
109
  runner_options[:server_timeout] = options.server_timeout
112
110
  runner_options[:spec_dir] = options.spec_dir
@@ -28,7 +28,7 @@ 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] || detect_server_port
31
+ port = options[:port]
32
32
  timeout = options[:server_timeout]
33
33
 
34
34
  case server
@@ -141,20 +141,6 @@ module Guard
141
141
  end
142
142
  end
143
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
-
158
144
  # Wait until the Jasmine test server is running.
159
145
  #
160
146
  # @param [Number] port the server port
@@ -78,6 +78,20 @@ module Guard
78
78
  end
79
79
  end
80
80
 
81
+ # Finds a free server port to use
82
+ #
83
+ # @return [Integer] a free server port
84
+ #
85
+ def find_free_server_port
86
+ server = TCPServer.new('127.0.0.1', 0)
87
+ port = server.addr[1]
88
+ server.close
89
+
90
+ port
91
+ rescue Errno::EADDRINUSE
92
+ retry
93
+ end
94
+
81
95
  # Cross-platform way of finding an executable in the $PATH.
82
96
  # http://stackoverflow.com/questions/2108727/which-in-ruby-checking-if-program-exists-in-path-from-ruby
83
97
  #
@@ -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.10.0'
4
+ VERSION = '1.10.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: 1.10.0
4
+ version: 1.10.1
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-19 00:00:00.000000000 Z
12
+ date: 2012-11-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: guard