guard-jasmine 1.7.0 → 1.8.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -344,6 +344,9 @@ The server options configures the server environment that is needed to run Guard
344
344
  # e.g. :development or :test
345
345
  # default: RAILS_ENV is exists, otherwise :development
346
346
 
347
+ :server_timeout => 30 # The number of seconds to wait for the Jasmine spec server
348
+ # default: 15
349
+
347
350
  :port => 9292 # Jasmine server port to use.
348
351
  # default: 8888
349
352
 
@@ -441,7 +444,7 @@ stack trace.
441
444
 
442
445
  ### Overwrite options when running all specs
443
446
 
444
- You may want to have different options when the spec runner runs all specs. You can specify the `:run_all` options
447
+ You may want to have different options when the spec runner runs all specs. You can specify the `:run_all` option
445
448
  as a Hash that contains any valid runner option and will overwrite the general options.
446
449
 
447
450
  ```ruby
@@ -525,26 +528,33 @@ Usage:
525
528
  guard-jasmine spec
526
529
 
527
530
  Options:
528
- -s, [--server=SERVER] # Server to start, either `auto`, `none`, `webrick`, `mongrel`,
529
- # `thin`, `jasmine_gem`
531
+ -s, [--server=SERVER] # Server to start, either `auto`, `webrick`, `mongrel`, `thin`,
532
+ # `unicorn`, `jasmine_gem` or `none`
530
533
  # Default: auto
531
534
  -p, [--port=N] # Server port to use
532
- # Default: 8888
533
- -u, [--url=URL] # The url of the Jasmine test runner
534
- # Default: http://localhost:8888/jasmine
535
+ # Default: 3001
536
+ -e, [--server-env=SERVER_ENV] # The server environment to use, for example `development`, `test` etc.
537
+ # Default: test
538
+ [--server-timeout=N] # The number of seconds to wait for the Jasmine spec server
539
+ # Default: 15
535
540
  -b, [--bin=BIN] # The location of the PhantomJS binary
536
- # Default: /usr/local/bin/phantomjs
537
- -t, [--timeout=N] # The maximum time in milliseconds to wait
538
- # for the spec runner to finish
541
+ -d, [--spec-dir=SPEC_DIR] # The directory with the Jasmine specs
542
+ # Default: spec/javascripts
543
+ -u, [--url=URL] # The url of the Jasmine test runner_options
544
+ # Default: http://localhost:3001/jasmine
545
+ -t, [--timeout=N] # The maximum time in milliseconds to wait for the spec
546
+ # runner to finish
539
547
  # Default: 10000
540
- -c, [--console=CONSOLE] # Whether to show console.log statements in the spec runner,
548
+ [--console=CONSOLE] # Whether to show console.log statements in the spec runner,
541
549
  # either `always`, `never` or `failure`
542
550
  # Default: failure
543
- -x, [--errors=ERRORS] # Whether to show errors in the spec runner,
551
+ [--errors=ERRORS] # Whether to show errors in the spec runner,
544
552
  # either `always`, `never` or `failure`
545
553
  # Default: failure
546
- -e, [--server-env=SERVER_ENV] # The server environment to use, for example `development`, `test`
547
- # Default: RAILS_ENV if exists, otherwise `test`
554
+ [--focus] # Specdoc focus to hide successful tests when at least one test fails
555
+ # Default: true
556
+ [--specdoc=SPECDOC] # Whether to show successes in the spec runner, either `always`, `never` or `failure`
557
+ # Default: always
548
558
 
549
559
  Run the Jasmine spec runner
550
560
  ```
@@ -695,7 +705,7 @@ $ guard-jasmine-debug
695
705
  ```
696
706
 
697
707
  The only argument that the script takes is the URL to the Jasmine runner, which defaults to
698
- `http://127.0.0.1:3000/Jasmine`. So you can for example just run a subset of the specs by changing the URL:
708
+ `http://127.0.0.1:3000/jasmine`. So you can for example just run a subset of the specs by changing the URL:
699
709
 
700
710
  ```bash
701
711
  $ guard-jasmine-debug http://127.0.0.1:3000/Jasmine?spec=YourSpec
@@ -23,6 +23,7 @@ module Guard
23
23
  DEFAULT_OPTIONS = {
24
24
  :server => :auto,
25
25
  :server_env => ENV['RAILS_ENV'] || 'development',
26
+ :server_timeout => 15,
26
27
  :port => 8888,
27
28
  :jasmine_url => 'http://localhost:8888/jasmine',
28
29
  :timeout => 10000,
@@ -46,6 +47,7 @@ module Guard
46
47
  # @param [Hash] options the options for the Guard
47
48
  # @option options [String] :server the server to use, either :auto, :none, :webrick, :mongrel, :thin, :jasmine_gem, or a custom rake task
48
49
  # @option options [String] :server_env the server environment to use, for example :development, :test
50
+ # @option options [Integer] :server_timeout the number of seconds to wait for the Jasmine spec server
49
51
  # @option options [String] :port the port for the Jasmine test server
50
52
  # @option options [String] :jasmine_url the url of the Jasmine test runner
51
53
  # @option options [String] :phantomjs_bin the location of the PhantomJS binary
@@ -88,7 +90,7 @@ module Guard
88
90
 
89
91
  Server.start(options[:server], options[:port], options[:server_env], options[:spec_dir]) unless options[:server] == :none
90
92
 
91
- if Jasmine.runner_available?(options[:jasmine_url])
93
+ if Jasmine.runner_available?(options)
92
94
  run_all if options[:all_on_start]
93
95
  end
94
96
  else
@@ -9,7 +9,7 @@ require 'guard/jasmine/util'
9
9
  module Guard
10
10
  class Jasmine
11
11
 
12
- # Small helper class to run the Jasmine runner once from the
12
+ # Small helper class to run the Jasmine runner_options once from the
13
13
  # command line. This can be useful to integrate guard-jasmine
14
14
  # into a continuous integration server.
15
15
  #
@@ -20,13 +20,7 @@ module Guard
20
20
 
21
21
  default_task :spec
22
22
 
23
- desc 'spec', 'Run the Jasmine spec runner'
24
-
25
- method_option :focus,
26
- :type => :boolean,
27
- :aliases => '-f',
28
- :default => true,
29
- :desc => 'Specdoc focus to hide successful tests when at least one test fails'
23
+ desc 'spec', 'Run the Jasmine spec runner_options'
30
24
 
31
25
  method_option :server,
32
26
  :type => :string,
@@ -40,17 +34,34 @@ module Guard
40
34
  :default => 3001,
41
35
  :desc => 'Server port to use'
42
36
 
43
- method_option :url,
37
+ method_option :server_env,
44
38
  :type => :string,
45
- :aliases => '-u',
46
- :default => 'http://localhost:3001/jasmine',
47
- :desc => 'The url of the Jasmine test runner'
39
+ :aliases => '-e',
40
+ :default => ENV['RAILS_ENV'] || 'test',
41
+ :desc => 'The server environment to use, for example `development`, `test` etc.'
42
+
43
+ method_option :server_timeout,
44
+ :type => :numeric,
45
+ :default => 15,
46
+ :desc => 'The number of seconds to wait for the Jasmine spec server'
48
47
 
49
48
  method_option :bin,
50
49
  :type => :string,
51
50
  :aliases => '-b',
52
51
  :desc => 'The location of the PhantomJS binary'
53
52
 
53
+ method_option :spec_dir,
54
+ :type => :string,
55
+ :aliases => '-d',
56
+ :default => 'spec/javascripts',
57
+ :desc => 'The directory with the Jasmine specs'
58
+
59
+ method_option :url,
60
+ :type => :string,
61
+ :aliases => '-u',
62
+ :default => 'http://localhost:3001/jasmine',
63
+ :desc => 'The url of the Jasmine test runner'
64
+
54
65
  method_option :timeout,
55
66
  :type => :numeric,
56
67
  :aliases => '-t',
@@ -59,33 +70,25 @@ module Guard
59
70
 
60
71
  method_option :console,
61
72
  :type => :string,
62
- :aliases => '-c',
63
73
  :default => 'failure',
64
74
  :desc => 'Whether to show console.log statements in the spec runner, either `always`, `never` or `failure`'
65
75
 
66
76
  method_option :errors,
67
77
  :type => :string,
68
- :aliases => '-x',
69
78
  :default => 'failure',
70
79
  :desc => 'Whether to show errors in the spec runner, either `always`, `never` or `failure`'
71
80
 
81
+ method_option :focus,
82
+ :type => :boolean,
83
+ :aliases => '-f',
84
+ :default => true,
85
+ :desc => 'Specdoc focus to hide successful tests when at least one test fails'
86
+
72
87
  method_option :specdoc,
73
88
  :type => :string,
74
89
  :default => :always,
75
90
  :desc => 'Whether to show successes in the spec runner, either `always`, `never` or `failure`'
76
91
 
77
- method_option :server_env,
78
- :type => :string,
79
- :aliases => '-e',
80
- :default => ENV['RAILS_ENV'] || 'test',
81
- :desc => 'The server environment to use, for example `development`, `test` etc.'
82
-
83
- method_option :spec_dir,
84
- :type => :string,
85
- :aliases => '-d',
86
- :default => 'spec/javascripts',
87
- :desc => 'The directory with the Jasmine specs'
88
-
89
92
  # Run the Guard::Jasmine::Runner with options from
90
93
  # the command line.
91
94
  #
@@ -94,34 +97,36 @@ module Guard
94
97
  def spec(*paths)
95
98
  paths = [options.spec_dir] if paths.empty?
96
99
 
97
- runner = {}
98
- runner[:jasmine_url] = options.url
99
- runner[:phantomjs_bin] = options.bin || CLI.which('phantomjs')
100
- runner[:timeout] = options.timeout
101
- runner[:port] = options.port
102
- runner[:server_env] = options.server_env
103
- runner[:spec_dir] = options.spec_dir
104
- runner[:console] = [:always, :never, :failure].include?(options.console.to_sym) ? options.console.to_sym : :failure
105
- runner[:errors] = [:always, :never, :failure].include?(options.errors.to_sym) ? options.errors.to_sym : :failure
106
- runner[:specdoc] = [:always, :never, :failure].include?(options.specdoc.to_sym) ? options.specdoc.to_sym : :always
107
- runner[:server] = options.server.to_sym
108
- runner[:focus] = options.focus
100
+ runner_options = {}
101
+ runner_options[:jasmine_url] = options.url
102
+ runner_options[:phantomjs_bin] = options.bin || CLI.which('phantomjs')
103
+ runner_options[:timeout] = options.timeout
104
+ runner_options[:port] = options.port
105
+ runner_options[:server_env] = options.server_env
106
+ runner_options[:server_timeout] = options.server_timeout
107
+ runner_options[:spec_dir] = options.spec_dir
108
+ runner_options[:console] = [:always, :never, :failure].include?(options.console.to_sym) ? options.console.to_sym : :failure
109
+ runner_options[:errors] = [:always, :never, :failure].include?(options.errors.to_sym) ? options.errors.to_sym : :failure
110
+ runner_options[:specdoc] = [:always, :never, :failure].include?(options.specdoc.to_sym) ? options.specdoc.to_sym : :always
111
+ runner_options[:server] = options.server.to_sym
112
+ runner_options[:focus] = options.focus
109
113
 
110
114
 
111
- runner[:notification] = false
112
- runner[:hide_success] = true
115
+ runner_options[:notification] = false
116
+ runner_options[:hide_success] = true
113
117
 
114
- runner[:max_error_notify] = 0
118
+ runner_options[:max_error_notify] = 0
115
119
 
116
- if CLI.phantomjs_bin_valid?(runner[:phantomjs_bin])
117
- ::Guard::Jasmine::Server.start(runner[:server], runner[:port], runner[:server_env], runner[:spec_dir]) unless runner[:server] == :none
120
+ if CLI.phantomjs_bin_valid?(runner_options[:phantomjs_bin])
121
+ ::Guard::Jasmine::Server.start(runner_options[:server], runner_options[:port], runner_options[:server_env], runner_options[:spec_dir]) unless runner_options[:server] == :none
118
122
 
119
- if CLI.runner_available?(runner[:jasmine_url])
120
- result = ::Guard::Jasmine::Runner.run(paths, runner)
123
+ if CLI.runner_available?(runner_options)
124
+ result = ::Guard::Jasmine::Runner.run(paths, runner_options)
121
125
  ::Guard::Jasmine::Server.stop
122
126
 
123
127
  Process.exit result.first ? 0 : 1
124
128
  else
129
+ ::Guard::Jasmine::Server.stop
125
130
  Process.exit 2
126
131
  end
127
132
 
@@ -1,5 +1,5 @@
1
1
  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
- watch(%r{app/assets/javascripts/(.+?)\.(js\.coffee|js|coffee)$}) { |m| "spec/javascripts/#{m[1]}_spec.#{m[2]}" }
4
+ watch(%r{app/assets/javascripts/(.+?)\.(js|coffee)}) { |m| "spec/javascripts/#{m[1]}_spec.#{m[2]}" }
5
5
  end
@@ -13,16 +13,18 @@ module Guard
13
13
  # If the runner is not available within 15 seconds, then
14
14
  # the availability check will cancel.
15
15
  #
16
- # @param [String] url the location of the test runner
16
+ # @param [Hash] options the options for the Guard
17
+ # @option options [Integer] :server_timeout the number of seconds to wait for the Jasmine spec server
18
+ # @option options [String] :jasmine_url the url of the Jasmine test runner
17
19
  # @return [Boolean] when the runner is available
18
20
  #
19
- def runner_available?(url)
20
- url = URI.parse(url)
21
+ def runner_available?(options)
22
+ url = URI.parse(options[:jasmine_url])
21
23
 
22
24
  begin
23
25
  ::Guard::Jasmine::Formatter.info "Waiting for Jasmine test runner at #{ url }"
24
26
 
25
- Timeout::timeout(15) do
27
+ Timeout::timeout(options[:server_timeout]) do
26
28
  Net::HTTP.start(url.host, url.port) do |http|
27
29
  response = http.request(Net::HTTP::Head.new(url.path))
28
30
  available = response.code.to_i == 200
@@ -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.7.0'
4
+ VERSION = '1.8.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.7.0
4
+ version: 1.8.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-08-10 00:00:00.000000000 Z
12
+ date: 2012-08-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: guard
@@ -138,7 +138,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
138
138
  version: '0'
139
139
  segments:
140
140
  - 0
141
- hash: 4241117556701944522
141
+ hash: -1717723720735593618
142
142
  required_rubygems_version: !ruby/object:Gem::Requirement
143
143
  none: false
144
144
  requirements: