Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Version 1.6: Minor updates to get Specky working again with rspec 2.8.

  • Loading branch information...
commit b6415ac2ca85238c224e8bb831bd88b4bfeacf91 1 parent 71065e2
@mahlonsmith mahlonsmith authored vim-scripts committed
Showing with 41 additions and 8 deletions.
  1. +5 −1 doc/specky.txt
  2. +35 −6 ruby/specky_formatter.rb
  3. +1 −1  syntax/rdoc.vim
View
6 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
@@ -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. >
View
41 ruby/specky_formatter.rb
@@ -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 ]
@@ -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
@@ -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
+
View
2  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
Please sign in to comment.
Something went wrong with that request. Please try again.