Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: guard/guard-jasmine
base: a478034931
...
head fork: guard/guard-jasmine
compare: e852f0176d
Checking mergeability… Don't worry, you can still create the pull request.
  • 9 commits
  • 10 files changed
  • 0 commit comments
  • 3 contributors
Commits on Mar 08, 2013
@eventualbuddha eventualbuddha Actually respect the server timeout option.
The problem with the way it was structured before is that Net::HTTP instances have their own read timeout of 60s. If you configured server timeout to be longer than that then the inner timeout will fire first and be caught by the rescue handler for Timeout::Error, which assumes that the configured server timeout has elapsed.

I ran into this with an app that, for some reason, is taking longer than 60s to respond (slow CI machine?). I had configured both timeout and server timeout to be 600,000s and have a global timeout on the CI server that will just kill anything that takes too long.
b4610cb
Commits on Mar 12, 2013
@netzpirat netzpirat Update CHANGELOG. 668308c
@netzpirat netzpirat Release 1.13.1 1f7e1f1
@twill88 twill88 Guard::Jasmine and Guard::Jasmine::Util were not being loaded correct…
…ly. Loading each seperately seems to fix the problem
18ebb0b
@twill88 twill88 ChildProcess is unable to find rake in Windows. This change makes the…
… file lookup more platform safe.
274ef30
Commits on Mar 13, 2013
@netzpirat netzpirat Update CHANGELOG. 5269bfd
@netzpirat netzpirat Release 1.13.2 374502a
Commits on Apr 03, 2013
@netzpirat netzpirat Add a `verbose` option to the CLI runner. (Closes #119) a81e741
@netzpirat netzpirat Release 1.14.0 e852f01
View
18 CHANGELOG.md
@@ -1,5 +1,18 @@
# Changelog
+## 1.14.0 - April 3, 2013
+
+- [#119](https://github.com/netzpirat/guard-jasmine/issues/119): Add a `verbose` option to the CLI runner.
+
+## 1.13.2 - March 13, 2013
+
+- [#118](https://github.com/netzpirat/guard-jasmine/pull/118): Fix Rake task execution on Windows. ([@twill88][])
+- [#117](https://github.com/netzpirat/guard-jasmine/issues/117): Fix load path issues on Windows. ([@twill88][])
+
+## 1.13.1 - March 12, 2013
+
+- [#116](https://github.com/netzpirat/guard-jasmine/pull/116): Actually respect the server timeout option. ([@eventualbuddha][])
+
## 1.13.0 - February 19, 2013
- [#112](https://github.com/netzpirat/guard-jasmine/pull/112): Faster Jasmine runner exception detection.
@@ -350,7 +363,7 @@
[@alexspeller]: https://github.com/alexspeller
[@andersjanmyr]: https://github.com/andersjanmyr
-[@andyw8]: https://github.com/andyw8
+[@andyw8]: https://github.com/andyw8
[@antono]: https://github.com/antono
[@arr-ee]: https://github.com/arr-ee
[@clumsysnake]: https://github.com/clumsysnake
@@ -359,7 +372,7 @@
[@dnagir]: https://github.com/dnagir
[@DouweM]: https://github.com/DouweM
[@esposito]: https://github.com/esposito
-[@eventualbuddha]: https://github.com/DouweM
+[@eventualbuddha]: https://github.com/eventualbuddha
[@huyhoang1970]: https://github.com/huyhoang1970
[@jasonm]: https://github.com/jasonm
[@mkdynamic]: https://github.com/mkdynamic
@@ -372,3 +385,4 @@
[@robotarmy]: https://github.com/robotarmy
[@ronan]: https://github.com/ronan
[@rymai]: https://github.com/rymai
+[@twill88]: https://github.com/twill88
View
1  README.md
@@ -616,6 +616,7 @@ Options:
# Default: auto
-p, [--port=N] # Server port to use
# Default: Random free port
+ [--verbose] # Show the server output in the console
-e, [--server-env=SERVER_ENV] # The server environment to use, for example `development`, `test` etc.
# Default: test
[--server-timeout=N] # The number of seconds to wait for the Jasmine spec server
View
6 lib/guard/jasmine/cli.rb
@@ -44,6 +44,11 @@ class CLI < Thor
:default => 60,
:desc => 'The number of seconds to wait for the Jasmine spec server'
+ method_option :verbose,
+ :type => :boolean,
+ :default => false,
+ :desc => 'Show the server output in the console'
+
method_option :rackup_config,
:type => :string,
:aliases => '-c',
@@ -140,6 +145,7 @@ def spec(*paths)
runner_options[:jasmine_url] = options.url || "http://localhost:#{ runner_options[:port] }#{ options.server.to_sym == :jasmine_gem ? '/' : '/jasmine' }"
runner_options[:phantomjs_bin] = options.bin || CLI.which('phantomjs')
runner_options[:timeout] = options.timeout
+ runner_options[:verbose] = options.verbose
runner_options[:server] = options.server.to_sym
runner_options[:server_env] = options.server_env
runner_options[:server_timeout] = options.server_timeout
View
1  lib/guard/jasmine/coverage.rb
@@ -1,6 +1,7 @@
# coding: utf-8
require 'tilt'
require 'childprocess'
+require 'guard/jasmine'
require 'guard/jasmine/util'
# Tilt template to generate coverage instrumented
View
15 lib/guard/jasmine/server.rb
@@ -37,9 +37,9 @@ def start(options)
when :unicorn
start_unicorn_server(port, options)
when :jasmine_gem
- start_rake_server(port, 'jasmine')
+ start_rake_server(port, 'jasmine', options)
else
- start_rake_server(port, server.to_s) unless server == :none
+ start_rake_server(port, server.to_s, options) unless server == :none
end
wait_for_server(port, timeout) unless server == :none
@@ -76,7 +76,7 @@ def start_rack_server(server, port, options)
self.process = ChildProcess.build(*['rackup', '-E', environment.to_s, '-p', port.to_s, '-s', server.to_s, rackup_config].compact)
self.process.environment['COVERAGE'] = options[:coverage].to_s
- self.process.io.inherit! if ::Guard.respond_to?(:options) && ::Guard.options && ::Guard.options[:verbose]
+ self.process.io.inherit! if options[:verbose]
self.process.start
rescue => e
@@ -99,7 +99,7 @@ def start_unicorn_server(port, options)
self.process = ChildProcess.build('unicorn_rails', '-E', environment.to_s, '-p', port.to_s)
self.process.environment['COVERAGE'] = options[:coverage].to_s
- self.process.io.inherit! if ::Guard.respond_to?(:options) && ::Guard.options && ::Guard.options[:verbose]
+ self.process.io.inherit! if options[:verbose]
self.process.start
rescue => e
@@ -110,12 +110,13 @@ def start_unicorn_server(port, options)
#
# @param [Number] port the server port
# @param [String] task the rake task name
+ # @option options [Symbol] server the rack server to use
#
- def start_rake_server(port, task)
+ def start_rake_server(port, task, options)
::Guard::UI.info "Guard::Jasmine starts Jasmine Gem test server on port #{ port }."
- self.process = ChildProcess.build('rake', task, "JASMINE_PORT=#{ port }")
- self.process.io.inherit! if ::Guard.respond_to?(:options) && ::Guard.options && ::Guard.options[:verbose]
+ self.process = ChildProcess.build('ruby', '-S', 'rake', task, "JASMINE_PORT=#{ port }")
+ self.process.io.inherit! if options[:verbose]
self.process.start
rescue => e
View
24 lib/guard/jasmine/util.rb
@@ -24,20 +24,20 @@ def runner_available?(options)
begin
::Guard::Jasmine::Formatter.info "Waiting for Jasmine test runner at #{ url }"
- Timeout::timeout(options[:server_timeout]) do
- Net::HTTP.start(url.host, url.port) do |http|
- response = http.request(Net::HTTP::Get.new(url.path))
- available = response.code.to_i == 200
-
- unless available
- ::Guard::Jasmine::Formatter.error "Jasmine test runner failed with status #{ response.code }"
- if response.body
- ::Guard::Jasmine::Formatter.error 'Please open the Jasmine runner in your browser for more information.'
- end
+ http = Net::HTTP.new(url.host, url.port)
+ http.read_timeout = options[:server_timeout]
+ http.start do
+ response = http.request(Net::HTTP::Get.new(url.path))
+ available = response.code.to_i == 200
+
+ unless available
+ ::Guard::Jasmine::Formatter.error "Jasmine test runner failed with status #{ response.code }"
+ if response.body
+ ::Guard::Jasmine::Formatter.error 'Please open the Jasmine runner in your browser for more information.'
end
-
- available
end
+
+ available
end
rescue Timeout::Error => e
View
2  lib/guard/jasmine/version.rb
@@ -1,6 +1,6 @@
module Guard
module JasmineVersion
# Guard::Jasmine version that is used for the Gem specification
- VERSION = '1.13.0'
+ VERSION = '1.14.0'
end
end
View
10 spec/guard/jasmine/cli_spec.rb
@@ -64,6 +64,11 @@
cli.start(['spec', '--timeout', '20000'])
end
+ it 'sets the verbose mode' do
+ runner.should_receive(:run).with(anything(), hash_including(:verbose => true)).and_return [true, []]
+ cli.start(['spec', '--verbose'])
+ end
+
it 'sets the server environment' do
runner.should_receive(:run).with(anything(), hash_including(:server_env => 'development')).and_return [true, []]
cli.start(['spec', '--server-env', 'development'])
@@ -134,6 +139,11 @@
cli.start(['spec'])
end
+ it 'sets the verbose mode' do
+ runner.should_receive(:run).with(anything(), hash_including(:verbose => false)).and_return [true, []]
+ cli.start(['spec'])
+ end
+
it 'sets the coverage support' do
runner.should_receive(:run).with(anything(), hash_including(:coverage => false)).and_return [true, []]
cli.start(['spec'])
View
4 spec/guard/jasmine/server_spec.rb
@@ -274,7 +274,7 @@
end
it 'starts the :jasmine rake task server' do
- server.should_receive(:start_rake_server).with(8888, 'jasmine')
+ server.should_receive(:start_rake_server).with(8888, 'jasmine', options)
server.start(options)
end
end
@@ -295,7 +295,7 @@
end
it 'starts a custom rake task server' do
- server.should_receive(:start_rake_server).with(8888, 'custom_server_strategy')
+ server.should_receive(:start_rake_server).with(8888, 'custom_server_strategy', options)
server.start(options)
end
end
View
22 spec/guard/jasmine/util_spec.rb
@@ -4,12 +4,20 @@
let(:util) { Class.new { extend Guard::Jasmine::Util } }
describe '.runner_available?' do
- context 'with the Jasmine runner available' do
- let(:http) { mock('http') }
+ let(:http) do
+ mock('http').tap do |http|
+ http.stub(:start).and_yield
+ http.stub(:read_timeout=).and_return(nil)
+ end
+ end
+
+ before do
+ Net::HTTP.stub(:new).and_return(http)
+ end
+ context 'with the Jasmine runner available' do
before do
http.stub_chain(:request, :code).and_return 200
- Net::HTTP.stub(:start).and_yield http
end
it 'does show that the runner is available' do
@@ -19,11 +27,9 @@
end
context 'without the Jasmine runner available' do
- let(:http) { mock('http') }
-
context 'because the connection is refused' do
before do
- Net::HTTP.stub(:start).and_raise Errno::ECONNREFUSED.new
+ http.stub(:start).and_raise Errno::ECONNREFUSED.new
end
it 'does show that the runner is not available' do
@@ -36,7 +42,6 @@
before do
http.stub_chain(:request, :code).and_return 404
http.stub_chain(:request, :body).and_return nil
- Net::HTTP.stub(:start).and_yield http
end
it 'does show that the runner is not available' do
@@ -59,14 +64,13 @@
context 'because a timeout occurs' do
before do
- Timeout.stub(:timeout).and_raise Timeout::Error
+ http.stub(:start).and_raise(Timeout::Error)
end
it 'does show that the runner is not available' do
Guard::Jasmine::Formatter.should_receive(:error).with 'Timeout waiting for the Jasmine test runner.'
util.runner_available?({ :jasmine_url => 'http://localhost:8888/jasmine', :server_timeout => 15 })
end
-
end
end
end

No commit comments for this range

Something went wrong with that request. Please try again.