Skip to content

Instantly share code, notes, and snippets.

@mislav
Created March 17, 2009 13:12
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save mislav/80533 to your computer and use it in GitHub Desktop.
Save mislav/80533 to your computer and use it in GitHub Desktop.
RSpec colorized unicode output with Rspactor integration
# this goes in the $HOME dir
# needs mislav-rspactor v0.3.2 and RSpec 1.2
RSpactor::Runner.class_eval do
alias old_formatter_opts formatter_opts
def formatter_opts
# update this path to where you saved unicode_formatter.rb
old_formatter_opts + " -r /Users/mislav/Projects/unicode_formatter -f UnicodeFormatter"
end
end
# Unicode formatter for RSpec STDOUT in the console
require 'spec/runner/formatter/base_text_formatter'
class UnicodeFormatter < Spec::Runner::Formatter::BaseTextFormatter
def example_failed(example, counter, failure)
@output.print colorize_failure('✗ ', failure)
@output.flush
end
def example_passed(example)
@output.print green('✓ ')
@output.flush
end
def example_pending(example, message)
super
@output.print yellow('● ')
@output.flush
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment