Created
March 3, 2015 06:00
-
-
Save torbiak/0db8a777b15c7675847b to your computer and use it in GitHub Desktop.
rspec formatter for vim :make
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
class VimFormatter | |
RSpec::Core::Formatters.register self, :example_failed, :example_passed, :dump_summary | |
def initialize(output) | |
@output = output | |
end | |
def example_passed(n) | |
@output << "PASSED: " << n.example.description << "\n\n" | |
end | |
def example_failed(notification) | |
@output << format(notification) + "\n\n" | |
end | |
def dump_summary(n) | |
passed = n.example_count | |
failed = n.failure_count | |
total = passed + failed | |
@output << "{passed: #{passed}, failed: #{failed}, total: #{total}, duration: #{n.duration.round(3)}}" | |
end | |
private | |
def format(n) | |
[ | |
"FAILED: " << n.description, | |
"%s: %s" % [n.example.location, n.exception.message], | |
n.formatted_backtrace.join("\n").gsub(':', '!'), | |
].join("\n") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment