Skip to content

Instantly share code, notes, and snippets.

@torbiak
Created March 3, 2015 06:00
Show Gist options
  • Save torbiak/0db8a777b15c7675847b to your computer and use it in GitHub Desktop.
Save torbiak/0db8a777b15c7675847b to your computer and use it in GitHub Desktop.
rspec formatter for vim :make
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