Last active
December 15, 2015 04:29
-
-
Save fweep/5202071 to your computer and use it in GitHub Desktop.
Vim quickfix formatter for RSpec 2
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
# Adapted from https://github.com/bronson/vim-runtest/blob/master/rspec_formatter.rb. | |
require 'rspec/core/formatters/base_text_formatter' | |
class VimFormatter < RSpec::Core::Formatters::BaseTextFormatter | |
def example_failed example | |
exception = example.execution_result[:exception] | |
path = $1 if exception.backtrace.find do |frame| | |
frame =~ %r{\b(spec/.*_spec\.rb:\d+)(?::|\z)} | |
end | |
message = format_message exception.message | |
path = format_caller path | |
output.puts "#{path}: #{example.example_group.description.strip} #{example.description.strip}: #{message.strip}" if path | |
end | |
def example_pending *args; end | |
def dump_failures *args; end | |
def dump_pending *args; end | |
def message msg; end | |
def dump_summary *args; end | |
def seed *args; end | |
private | |
def format_message msg | |
msg.gsub("\n", ' ')[0,80] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment