File tree Expand file tree Collapse file tree 5 files changed +37
-10
lines changed Expand file tree Collapse file tree 5 files changed +37
-10
lines changed Original file line number Diff line number Diff line change
1
+ # -*- encoding : utf-8 -*-
1
2
class RSpecContextRenderer
2
3
# context: an html representation of an rspec context from rspec output
3
4
# counts: a hash with :passed, :failed, :not_implemented counters
4
5
def initialize ( context , counts )
5
6
@context = context
6
7
@counts = counts
7
-
8
+ @classes = { "passed" => "+" , "failed" => "-" , "not_implemented" => "#" }
8
9
render_context_header
9
10
render_specs
10
11
puts " "
@@ -18,15 +19,15 @@ def render_context_header
18
19
def render_specs
19
20
( @context /"dd" ) . each do |dd |
20
21
render_spec_descriptor ( dd )
21
- FailureRenderer . new ( dd /"div[@class='failure']" ) if dd [ :class ] == "spec failed"
22
+ FailureRenderer . new ( dd /"div[@class~ ='failure']" ) if dd [ :class ] =~ / failed/
22
23
end
23
24
end
24
25
25
26
def render_spec_descriptor ( dd )
26
- classes = { "spec passed" => "+" , "spec failed" => "-" , "spec not_implemented" => "#" }
27
27
txt = ( dd /"span:first" ) . inner_html
28
- puts "#{ classes [ dd [ :class ] ] } #{ txt } "
29
- outcome = dd [ :class ] . gsub ( /\s *spec\s */ , '' ) . to_sym
28
+ clazz = dd [ :class ] . gsub ( /(?:example|spec) / , '' )
29
+ puts "#{ @classes [ clazz ] } #{ txt } "
30
+ outcome = clazz . to_sym
30
31
@counts [ outcome ] += 1
31
32
end
32
33
end
Original file line number Diff line number Diff line change
1
+ # -*- encoding : utf-8 -*-
1
2
class FailureRenderer
2
3
include StringUtil
3
4
@@ -21,7 +22,7 @@ def failure_location
21
22
end
22
23
23
24
def failure_message
24
- indent ( unescape ( ( @failure /"div[@class='message']/pre" ) . inner_html . gsub ( /\n / , '' ) . gsub ( /\s +/ , ' ' ) ) )
25
+ indent ( unescape ( ( @failure /"div[@class~ ='message']/pre" ) . inner_html . gsub ( /\n / , '' ) . gsub ( /\s +/ , ' ' ) ) )
25
26
end
26
27
27
28
def backtrace_details
@@ -36,7 +37,11 @@ def backtrace_details
36
37
end
37
38
38
39
def backtrace_lines
39
- ( @failure /"pre[@class='ruby']/code" ) . inner_html . scan ( /(<span class="linenum">)(\d +)(<\/ span>)(.*)/ )
40
+ ( @failure /"pre[@class='ruby']/code" ) . inner_html . scan ( /(<span class="linenum">)(\d +)(<\/ span>)(.*)/ ) . reject { |line | line [ 3 ] =~ ignore_line_if_matches }
41
+ end
42
+
43
+ def ignore_line_if_matches
44
+ /install syntax to get syntax highlighting/
40
45
end
41
46
42
47
end
Original file line number Diff line number Diff line change
1
+ # -*- encoding : utf-8 -*-
1
2
require "rubygems"
2
3
require "hpricot"
3
4
require 'cgi'
@@ -25,6 +26,7 @@ def render_header
25
26
stats . map! do |script |
26
27
script . inner_html . scan ( /".*"/ ) . first . gsub ( /<\/ ?strong>/ , "" ) . gsub ( /\" / , '' )
27
28
end
29
+ # results in ["Finished in 0.00482 seconds", "2 examples, 1 failure"]
28
30
failure_success_messages , other_stats = stats . partition { |stat | stat =~ /failure/ }
29
31
render_red_green_header ( failure_success_messages . first )
30
32
other_stats . each do |stat |
@@ -51,7 +53,7 @@ def render_red_green_header(failure_success_messages)
51
53
end
52
54
53
55
def render_examples
54
- ( @doc /"div[@class='example_group']" ) . each do |context |
56
+ ( @doc /"div[@class~ ='example_group']" ) . each do |context |
55
57
RSpecContextRenderer . new ( context , @counts )
56
58
end
57
59
end
Original file line number Diff line number Diff line change @@ -182,9 +182,11 @@ function! s:SwitchToWindowByName(buffername)
182
182
endfunction
183
183
184
184
function ! s: TryToOpen ()
185
+ " Search up to find '*_spec.rb'
186
+ call search (" _spec" ," bcW" )
185
187
let l: line = getline (" ." )
186
- if match (l: line ,' ^ [\/\.] ' )<0
187
- call s: error_msg (" No file found." )
188
+ if match (l: line ,' ^ .*_spec.rb ' )<0
189
+ call s: error_msg (" No spec file found." )
188
190
return
189
191
end
190
192
let l: tokens = split (l: line ," :" )
Original file line number Diff line number Diff line change
1
+ # -*- encoding : utf-8 -*-
2
+ class TestVimRspec
3
+ def testme
4
+ true
5
+ end
6
+ end
7
+ describe "vim-rspec" do
8
+ it "shows failures in red" do
9
+ false . should == TestVimRspec . new . testme
10
+ end
11
+
12
+ it "shows successes in green" do
13
+ true . should be_true
14
+ end
15
+
16
+ xit "shows pending specs in yellow"
17
+ end
You can’t perform that action at this time.
0 commit comments