Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add a `verbose` option to the CLI runner. (Closes #119)

  • Loading branch information...
commit a81e741c08a48fe21eaecbb1ce0d4c3fc5afaa5e 1 parent 374502a
@netzpirat netzpirat authored
View
4 CHANGELOG.md
@@ -1,5 +1,9 @@
# Changelog
+## Master
+
+- [#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][])
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
13 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('ruby', '-S', 'rake', task, "JASMINE_PORT=#{ port }")
- 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
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
Please sign in to comment.
Something went wrong with that request. Please try again.