Created
December 3, 2012 15:40
-
-
Save thedelchop/4195788 to your computer and use it in GitHub Desktop.
Here is the TmuxNotifier and the .rspec changes needed to use it.
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
--color -f TmuxNotifier |
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 'rspec/core/formatters/progress_formatter' | |
class TmuxNotifier < RSpec::Core::Formatters::ProgressFormatter | |
def initialize(output) | |
@tmux_message = "" | |
@write_to_tmux = true | |
super | |
end | |
def dump_summary(duration, example_count, failure_count, pending_count) | |
summary = pluralize(example_count, "example") | |
summary << ", " << pluralize(failure_count, "failure") | |
summary << ", #{pending_count} pending" if pending_count > 0 | |
system "tmux set quiet on" | |
if pending_count > 0 | |
system "tmux set status-right-bg yellow" | |
elsif failure_count > 0 | |
system "tmux set status-right-bg red" | |
else | |
system "tmux set status-right-bg green" | |
end | |
@tmux_message = summary + @tmux_message | |
super | |
end | |
def dump_failure_info(example) | |
if @write_to_tmux | |
exception = example.execution_result[:exception] | |
@tmux_message << " Failure/Error: #{read_failed_line(exception, example).strip} " | |
exception.message.each_line do |line| | |
@tmux_message << "#{line.gsub("\n","").strip} " | |
end | |
@write_to_tmux = false | |
end | |
super | |
end | |
def close | |
system "tmux set status-right-length #{@tmux_message.length + 5}" | |
system "tmux set status-right '#{@tmux_message.gsub('`','').gsub("'",'')}'" | |
super | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Not sure if the logic here is what you intended, but when you have failing and pending specs you'll get a yellow background.
In rgrmux I've changed this so that the background is red if there are any failing specs.