Skip to content

Commit

Permalink
Merge pull request guard#47 from DouweM/cli-spec-result-format
Browse files Browse the repository at this point in the history
Format spec results on the CLI exactly like RSpec does.
  • Loading branch information
netzpirat committed Mar 17, 2012
2 parents 41f5623 + af0c206 commit 5a972b4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
26 changes: 16 additions & 10 deletions lib/guard/jasmine/runner.rb
Expand Up @@ -205,24 +205,30 @@ def notify_runtime_error(result, options)
# @option options [Boolean] :hide_success hide success message notification
#
def notify_spec_result(result, options)
specs = result['stats']['specs']
failures = result['stats']['failures']
time = result['stats']['time']
plural = failures == 1 ? '' : 's'

message = "#{ specs } specs, #{ failures } failure#{ plural }\nin #{ time } seconds"
passed = failures == 0

specs = result['stats']['specs']
failures = result['stats']['failures']
time = result['stats']['time']
specs_plural = specs == 1 ? '' : 's'
failures_plural = failures == 1 ? '' : 's'

Formatter.info("\nFinished in #{ time } seconds")

message = "#{ specs } spec#{ specs_plural }, #{ failures } failure#{ failures_plural }"
full_message = "#{ message }\nin #{ time } seconds"
passed = failures == 0

if passed
report_specdoc(result, passed, options) if options[:specdoc] == :always
Formatter.success(message)
Formatter.notify(message, :title => 'Jasmine suite passed') if options[:notification] && !options[:hide_success]
Formatter.notify(full_message, :title => 'Jasmine suite passed') if options[:notification] && !options[:hide_success]
else
report_specdoc(result, passed, options) if options[:specdoc] != :never
Formatter.error(message)
notify_errors(result, options)
Formatter.notify(message, :title => 'Jasmine suite failed', :image => :failed, :priority => 2) if options[:notification]
Formatter.notify(full_message, :title => 'Jasmine suite failed', :image => :failed, :priority => 2) if options[:notification]
end

Formatter.info("Done.\n")
end

# Specdoc like formatting of the result.
Expand Down
6 changes: 3 additions & 3 deletions spec/guard/jasmine/runner_spec.rb
Expand Up @@ -218,7 +218,7 @@
formatter.should_not_receive(:suite_name)
formatter.should_not_receive(:spec_failed)
formatter.should_receive(:error).with(
"3 specs, 2 failures\nin 0.007 seconds"
"3 specs, 2 failures"
)
runner.run(['spec/javascripts/x/b.js.coffee'], defaults.merge({ :specdoc => :never }))
end
Expand Down Expand Up @@ -416,7 +416,7 @@
' ✔ Success nested test tests something'
)
formatter.should_receive(:success).with(
"3 specs, 0 failures\nin 0.009 seconds"
"3 specs, 0 failures"
)
runner.run(['spec/javascripts/x/t.js'], defaults.merge({ :specdoc => :always }))
end
Expand Down Expand Up @@ -456,7 +456,7 @@
)
formatter.should_not_receive(:suite_name)
formatter.should_receive(:success).with(
"3 specs, 0 failures\nin 0.009 seconds"
"3 specs, 0 failures"
)
runner.run(['spec/javascripts/x/t.js'], defaults.merge({ :specdoc => :never }))
end
Expand Down

0 comments on commit 5a972b4

Please sign in to comment.