C0 code coverage information

Generated on Mon Aug 13 01:18:53 -0400 2007 with rcov 0.8.0


Code reported as executed by Ruby looks like this...
and this: this line is also marked as covered.
Lines considered as run by rcov, but not reported by Ruby, look like this,
and this: these lines were inferred by rcov (using simple heuristics).
Finally, here's a line marked as not executed.
Name Total lines Lines of code Total coverage Code coverage
lib/autotest/rspec.rb 95 68
100.0% 
100.0% 
 1 require 'autotest'
 2 
 3 class RspecCommandError < StandardError; end
 4 
 5 class Autotest::Rspec < Autotest
 6   
 7   def initialize(kernel=Kernel, separator=File::SEPARATOR, alt_separator=File::ALT_SEPARATOR) # :nodoc:
 8     super()
 9     @kernel, @separator, @alt_separator = kernel, separator, alt_separator
10     @spec_command = spec_command
11 
12     # watch out: Ruby bug (1.8.6):
13     # %r(/) != /\//
14     # since Ruby compares the REGEXP source, not the resulting pattern
15     @test_mappings = {
16       %r%^spec/.*\.rb$% => kernel.proc { |filename, _| 
17         filename 
18       },
19       %r%^lib/(.*)\.rb$% => kernel.proc { |_, m| 
20         ["spec/#{m[1]}_spec.rb"] 
21       },
22       %r%^spec/(spec_helper|shared/.*)\.rb$% => kernel.proc { 
23         files_matching %r%^spec/.*_spec\.rb$% 
24       }
25     }
26   end
27   
28   def tests_for_file(filename)
29     super.select { |f| @files.has_key? f }
30   end
31   
32   alias :specs_for_file :tests_for_file
33   
34   def failed_results(results)
35     results.scan(/^\d+\)\n(?:\e\[\d*m)?(?:.*?Error in )?'([^\n]*)'(?: FAILED)?(?:\e\[\d*m)?\n(.*?)\n\n/m)
36   end
37 
38   def handle_results(results)
39     @files_to_test = consolidate_failures failed_results(results)
40     unless @files_to_test.empty? then
41       hook :red
42     else
43       hook :green
44     end unless $TESTING
45     @tainted = true unless @files_to_test.empty?
46   end
47 
48   def consolidate_failures(failed)
49     filters = Hash.new { |h,k| h[k] = [] }
50     failed.each do |spec, failed_trace|
51       @files.keys.select{|f| f =~ /spec\//}.each do |f|
52         if failed_trace =~ Regexp.new(f)
53           filters[f] << spec
54           break
55         end
56       end
57     end
58     return filters
59   end
60 
61   def make_test_cmd(files_to_test)
62     return "#{ruby} -S #{@spec_command} #{add_options_if_present} #{files_to_test.keys.flatten.join(' ')}"
63   end
64   
65   def add_options_if_present
66     File.exist?("spec/spec.opts") ? "-O spec/spec.opts " : ""
67   end
68 
69   # Finds the proper spec command to use.  Precendence
70   # is set in the lazily-evaluated method spec_commands.  Alias + Override
71   # that in ~/.autotest to provide a different spec command
72   # then the default paths provided.
73   def spec_command
74     spec_commands.each do |command|
75       if File.exists?(command)
76         return @alt_separator ? (command.gsub @separator, @alt_separator) : command
77       end
78     end
79     
80     raise RspecCommandError, "No spec command could be found!"
81   end
82   
83   # Autotest will look for spec commands in the following
84   # locations, in this order:
85   #
86   #   * bin/spec
87   #   * default spec bin/loader installed in Rubygems
88   def spec_commands
89     [
90       File.join('bin', 'spec'),
91       File.join(Config::CONFIG['bindir'], 'spec')
92     ]
93   end
94 
95 end

Generated using the rcov code coverage analysis tool for Ruby version 0.8.0.

Valid XHTML 1.0! Valid CSS!