Skip to content

Commit

Permalink
Version 1.6: Minor updates to get Specky working again with rspec 2.8.
Browse files Browse the repository at this point in the history
  • Loading branch information
mahlonsmith authored and vim-scripts committed Mar 7, 2012
1 parent 71065e2 commit b6415ac
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 8 deletions.
6 changes: 5 additions & 1 deletion doc/specky.txt
@@ -1,4 +1,4 @@
*specky.txt* Last change: $Id: specky.txt,v cd1f3381c1ed 2010/12/25 04:01:10 mahlon $
*specky.txt* Last change: $Id: specky.txt,v ed72213b1788 2012/02/11 00:08:43 mahlon $

VIM REFERENCE MANUAL by Mahlon E. Smith

Expand Down Expand Up @@ -106,6 +106,10 @@ ways.
-r ~/.vim/bundle/specky/ruby/specky_formatter
-f SpeckyFormatter
You can also use both of these methods, and use the
'SpeckyConsoleFormatter' class from your .rspec file, if it suits
your fancy.
After that is taken care of, then just set up your keybindings in your
.vimrc. Here's what my config looks like. >
Expand Down
41 changes: 35 additions & 6 deletions ruby/specky_formatter.rb
Expand Up @@ -76,19 +76,26 @@ def example_failed( example )
###
def dump_failures
self.out "\n" unless @failures.empty?
cwd = Regexp.new( Dir.pwd )
bt_regexp = /(.+?):(\d+)(|:\d+)/

@failures.each_with_index do |example, index|
desc = example.metadata[ :full_description ]
exception = example.execution_result[ :exception ]
file = line = nil

if exception.backtrace.first =~ /(.*):(\d+)/
file, line = $1, $2.to_i
end
# remove files that are not in within the cwd.
#
# this isn't optimal, but it does stay within specky's notion of
# running it from within the project directory, and makes sure we don't
# inadvertently display code from rspec itself.
#
bt_file = exception.backtrace.find { |line| line =~ bt_regexp && line =~ cwd }
file, line = $1, $2.to_i if bt_file =~ bt_regexp
self.out "FAILURE - #%d)" % [ index + 1 ]
self.out "%s:%d" % [ file, line ]
self.out "%s:%d" % [ file, line ] if bt_file

if RSpec::Core::PendingExampleFixedError === exception
if exception.respond_to?( :pending_fixed? ) && exception.pending_fixed?
self.out "%s FIXED" % [ desc ]
self.out "Expected pending '%s' to fail. No error was raised." % [
example.metadata[ :execution_result ][ :pending_message ]
Expand All @@ -108,7 +115,7 @@ def dump_failures
end
end

self.out exception_source( file, line ) if file && line
self.out exception_source( file, line-1 ) if file && line
end
end

Expand Down Expand Up @@ -180,3 +187,25 @@ def format_example( example )
end
end # SpeckyFormatter


### Identical to the regular SpeckyFormatter, but it puts summary
### information at the bottom of the screen instead of the top, and just
### spits out rudamentary failure info.
###
class SpeckyFormatterConsole < SpeckyFormatter
def close
puts "Failures:" unless @failures.empty?
@failures.each do |test|
metadata = test.metadata
msg = "- %s\n %s\n %s:%d\n\n" % [
metadata[:full_description],
test.exception.message,
metadata[:file_path],
metadata[:line_number]
]
puts msg
end
output.puts @summary
end
end

2 changes: 1 addition & 1 deletion syntax/rdoc.vim
@@ -1,6 +1,6 @@
"
" specky: syntax highlighting for 'rdoc' output
" $Id$
" $Id: rdoc.vim,v 6b33188f1694 2009/03/22 00:39:19 mahlon $


" Separator lines
Expand Down

0 comments on commit b6415ac

Please sign in to comment.