Created
February 13, 2020 20:18
-
-
Save kellishaver/79eda09dae357f76748b1e61ac8a2293 to your computer and use it in GitHub Desktop.
Fun Rspec matcher
This file contains hidden or 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
# lives in ~/.rspec | |
# update path to formatter.rb as needed - I also put it in ~/ :) | |
--require ~/formatter.rb --format GroupingFormatter |
This file contains hidden or 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/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