Geminstaller C0 Coverage Information - RCov

/Users/woolley/.rvm/gems/ruby-1.8.7-p174@geminstaller/gems/rspec-1.3.0/lib/spec/runner/line_number_query.rb

Name Total Lines Lines of Code Total Coverage Code Coverage
/Users/woolley/.rvm/gems/ruby-1.8.7-p174@geminstaller/gems/rspec-1.3.0/lib/spec/runner/line_number_query.rb 78 67
29.49%
19.40%

Key

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.

Coverage Details

1 module Spec
2   module Runner
3     # Parses a spec file and finds the nearest example for a given line number.
4     class LineNumberQuery
5       attr_reader :best_match
6 
7       def initialize(run_options)
8         @best_match = {}
9         @run_options = run_options
10       end
11 
12       def spec_name_for(file, line_number)
13         best_match.clear
14         file = File.expand_path(file)
15         determine_best_match(file, line_number)
16         if best_match[:example_group]
17           if best_match[:example]
18             "#{best_match[:example_group].description} #{best_match[:example].description}"
19           else
20             best_match[:example_group].description
21           end
22         else
23           nil
24         end
25       end
26 
27       def example_line_for(file, line_number)
28         determine_best_match(file, line_number)
29         best_match[:line]
30       end
31     
32     protected
33     
34       def determine_best_match(file, line_number)
35         best_match.clear
36         file = File.expand_path(file)
37         @run_options.example_groups.each do |example_group|
38           next unless example_group.location
39           consider_example_group_for_best_match(example_group, file, line_number)
40 
41           example_group.examples.each do |example|
42             consider_example_for_best_match(example, example_group, file, line_number)
43           end
44         end
45       end
46 
47       def consider_example_group_for_best_match(example_group, file, line_number)
48         example_group_file, example_group_line = parse_location(example_group.location)
49         if is_best_match?(file, line_number, example_group_file, example_group_line)
50           best_match.clear
51           best_match[:example_group] = example_group
52           best_match[:line] = example_group_line
53         end
54       end
55 
56       def consider_example_for_best_match(example, example_group, file, line_number)
57         example_file, example_line = parse_location(example.location)
58         if is_best_match?(file, line_number, example_file, example_line)
59           best_match.clear
60           best_match[:example_group] = example_group
61           best_match[:example] = example
62           best_match[:line] = example_line
63         end
64       end
65 
66       def is_best_match?(file, line_number, example_file, example_line)
67         file == File.expand_path(example_file) &&
68                 example_line <= line_number &&
69                 example_line > best_match[:line].to_i
70       end
71       
72       def parse_location(location)
73         location =~ /(.*)\:(\d*)(\:|$)/
74         return $1, Integer($2)
75       end
76     end
77   end
78 end

Generated on Mon May 10 23:40:28 -0700 2010 with rcov 0.9.8