]> git.r.bdr.sh - rbdr/dotfiles/blame - vim/plugin/vim-rspec.rb
Remove task Warrior
[rbdr/dotfiles] / vim / plugin / vim-rspec.rb
CommitLineData
0d23b6e5
BB
1require "rubygems"
2require "hpricot"
3
4doc = Hpricot(STDIN.read)
5h1 = (doc/"h1")
6classes = {"spec passed"=>"+","spec failed"=>"-","spec not_implemented"=>"#"}
7
8puts "* #{h1.inner_html}"
9
10stats = (doc/"script").select {|script| script.innerHTML =~ /duration|totals/ }.map {|script| script.inner_html.scan(/".*"/).first.gsub(/<\/?strong>/,"") }
11stats.each do |stat|
12 puts "* #{stat.gsub(/\"/,'')}"
13end
14puts "* Parsed with Hpricot (http://wiki.github.com/why/hpricot)"
15puts " "
16
17(doc/"div[@class='example_group']").each do |example|
18 puts "[#{(example/"dl/dt").inner_html}]"
19 (example/"dd").each do |dd|
20 txt = (dd/"span:first").inner_html
21 puts "#{classes[dd[:class]]} #{txt}"
22 next if dd[:class]!="spec failed"
23 failure = (dd/"div[@class='failure']")
24 msg = (failure/"div[@class='message']/pre").inner_html
25 back = (failure/"div[@class='backtrace']/pre").inner_html
26 ruby = (failure/"pre[@class='ruby']/code").inner_html.scan(/(<span class="linenum">)(\d+)(<\/span>)([^<]+)/).map {|elem| " "+elem[1]+": "+elem[3].chomp+"\n"}.join
27 puts " #{msg}"
28 puts " #{back}"
29 puts ruby
30 end
31 puts " "
32end