Created
February 26, 2010 08:26
-
-
Save rud/315530 to your computer and use it in GitHub Desktop.
ImmediateFeedbackFormatterGrowl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec/runner/formatter/base_text_formatter' | |
# Code is based on standard SpecdocFormatter, but will print full error details as soon as they are found. | |
# Successful or pending examples are written only as a dot in the output. Header is only printed if errors occur. | |
# | |
# To use it, add the following to your spec/spec.opts: | |
# --require | |
# spec/support/rspec_immediate_feedback_formatter_growl.rb | |
# --format | |
# Spec::Runner::Formatter::ImmediateFeedbackFormatterGrowl | |
module Spec | |
module Runner | |
module Formatter | |
class ImmediateFeedbackFormatterGrowl < BaseTextFormatter | |
def add_example_group(example_group) | |
super | |
@current_group = example_group.description | |
end | |
def example_failed(example, counter, failure) | |
fail_img = "#{File.basename(__FILE__)}/rails_fail.png" | |
cmd = "growlnotify --name rspec --identifier rails_fail --image #{fail_img} --message \"#{failure.header}\" --priority Emergency" | |
# puts cmd | |
system cmd | |
if @current_group | |
output.puts | |
output.puts @current_group | |
@current_group = nil # only print the group name once | |
end | |
message = if failure.expectation_not_met? | |
"- #{example.description} (FAILED - #{counter})" | |
else | |
"- #{example.description} (ERROR - #{counter})" | |
end | |
output.print red("F") | |
dump_failure(counter, failure) # dump stacktrace immediately | |
output.flush | |
end | |
def example_passed(example) | |
output.print green(".") | |
output.flush | |
end | |
def example_pending(example, message) | |
super | |
output.print yellow("P") | |
output.flush | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment