Skip to content

Instantly share code, notes, and snippets.

@kellishaver
Created February 13, 2020 20:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kellishaver/79eda09dae357f76748b1e61ac8a2293 to your computer and use it in GitHub Desktop.
Save kellishaver/79eda09dae357f76748b1e61ac8a2293 to your computer and use it in GitHub Desktop.
Fun Rspec matcher
# lives in ~/.rspec
# update path to formatter.rb as needed - I also put it in ~/ :)
--require ~/formatter.rb --format GroupingFormatter
require 'rspec/core/formatters/console_codes'
class GroupingFormatter
RSpec::Core::Formatters.register self, :dump_summary, :close, :example_passed, :example_failed, :example_pending
def initialize output
@output = output
end
def example_passed notification # ExampleNotification
@output << RSpec::Core::Formatters::ConsoleCodes.wrap("☺", :success)
end
def example_failed notification # FailedExampleNotification
@output << RSpec::Core::Formatters::ConsoleCodes.wrap("☹", :failure)
end
def example_pending notification # ExampleNotification
@output << RSpec::Core::Formatters::ConsoleCodes.wrap("⚇", :pending)
end
def dump_summary notification # SummaryNotification
@output << "\n\nFinished in #{RSpec::Core::Formatters::Helpers.format_duration(notification.duration)}."
end
def close notification # NullNotification
@output << "\n"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment