From 27a1019700e5fb3a56beeeda45384e3642e39d84 Mon Sep 17 00:00:00 2001 From: Laust Rud Jacobsen Date: Fri, 3 Aug 2012 14:44:44 +0200 Subject: [PATCH] Guard::Jasmine::CLI: making specdoc an option instead of forced to :always This means we can optionally get quiet spec output from with the rake-task --- lib/guard/jasmine/cli.rb | 7 ++++++- spec/guard/jasmine/cli_spec.rb | 16 +++++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/lib/guard/jasmine/cli.rb b/lib/guard/jasmine/cli.rb index 83e392a..1c195fd 100644 --- a/lib/guard/jasmine/cli.rb +++ b/lib/guard/jasmine/cli.rb @@ -69,6 +69,11 @@ class CLI < Thor :default => 'failure', :desc => 'Whether to show errors in the spec runner, either `always`, `never` or `failure`' + method_option :specdoc, + :type => :string, + :default => :always, + :desc => 'Whether to show successes in the spec runner, either `always`, `never` or `failure`' + method_option :server_env, :type => :string, :aliases => '-e', @@ -98,6 +103,7 @@ def spec(*paths) runner[:spec_dir] = options.spec_dir runner[:console] = [:always, :never, :failure].include?(options.console.to_sym) ? options.console.to_sym : :failure runner[:errors] = [:always, :never, :failure].include?(options.errors.to_sym) ? options.errors.to_sym : :failure + runner[:specdoc] = [:always, :never, :failure].include?(options.specdoc.to_sym) ? options.specdoc.to_sym : :always runner[:server] = options.server.to_sym runner[:focus] = options.focus @@ -106,7 +112,6 @@ def spec(*paths) runner[:hide_success] = true runner[:max_error_notify] = 0 - runner[:specdoc] = :always if CLI.phantomjs_bin_valid?(runner[:phantomjs_bin]) ::Guard::Jasmine::Server.start(runner[:server], runner[:port], runner[:server_env], runner[:spec_dir]) unless runner[:server] == :none diff --git a/spec/guard/jasmine/cli_spec.rb b/spec/guard/jasmine/cli_spec.rb index cb2631a..e8c86c4 100644 --- a/spec/guard/jasmine/cli_spec.rb +++ b/spec/guard/jasmine/cli_spec.rb @@ -153,6 +153,17 @@ runner.should_receive(:run).with(anything(), hash_including(:server_env => 'test')).and_return [true, []] cli.start(['spec']) end + + it 'sets the specdoc to always by default' do + runner.should_receive(:run).with(anything(), hash_including(:specdoc => :always)).and_return [true, []] + cli.start(['spec']) + end + + it 'sets the specdoc to failure' do + runner.should_receive(:run).with(anything(), hash_including(:specdoc => :failure)).and_return [true, []] + cli.start(['spec', '--specdoc', 'failure']) + end + end end @@ -171,11 +182,6 @@ runner.should_receive(:run).with(anything(), hash_including(:max_error_notify => 0)).and_return [true, []] cli.start(['spec']) end - - it 'sets the specdoc to always' do - runner.should_receive(:run).with(anything(), hash_including(:specdoc => :always)).and_return [true, []] - cli.start(['spec']) - end end context 'without a valid phantomjs executable' do