Geminstaller C0 Coverage Information - RCov

/Users/woolley/.rvm/gems/ruby-1.8.7-p174@geminstaller/gems/rspec-1.3.0/lib/spec/runner/formatter/base_text_formatter.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/formatter/base_text_formatter.rb 142 113
70.42%
62.83%

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 require 'spec/runner/formatter/base_formatter'
2 require 'fileutils'
3 
4 module Spec
5   module Runner
6     module Formatter
7       # Baseclass for text-based formatters. Can in fact be used for
8       # non-text based ones too - just ignore the +output+ constructor
9       # argument.
10       class BaseTextFormatter < BaseFormatter
11         attr_reader :output, :example_group
12         # Creates a new instance that will write to +output+. If +output+ is a
13         # String, output will be written to the File with that name, otherwise
14         # +output+ is exected to be an IO (or an object that responds to #puts
15         # and #write).
16         def initialize(options, output)
17           @options = options
18           if String === output
19             FileUtils.mkdir_p(File.dirname(output))
20             @output = File.open(output, 'w')
21           else
22             @output = output
23           end
24           @pending_examples = []
25         end
26 
27         def example_group_started(example_group_proxy)
28           @example_group = example_group_proxy
29         end
30         
31         def example_pending(example, message, deprecated_pending_location=nil)
32           @pending_examples << ["#{@example_group.description} #{example.description}", message, example.location]
33         end
34         
35         def dump_failure(counter, failure)
36           @output.puts
37           @output.puts "#{counter.to_s})"
38           @output.puts colorize_failure("#{failure.header}\n#{failure.exception.message}", failure)
39           @output.puts format_backtrace(failure.exception.backtrace)
40           @output.flush
41         end
42         
43         def colorize_failure(message, failure)
44           failure.pending_fixed? ? blue(message) : red(message)
45         end
46         
47         def colourise(message, failure)
48           Spec::deprecate("BaseTextFormatter#colourise", "colorize_failure")
49           colorize_failure(message, failure)
50         end
51         
52         def dump_summary(duration, example_count, failure_count, pending_count)
53           return if dry_run?
54           @output.puts
55           @output.puts "Finished in #{duration} seconds"
56           @output.puts
57 
58           summary = "#{example_count} example#{'s' unless example_count == 1}, #{failure_count} failure#{'s' unless failure_count == 1}"
59           summary << ", #{pending_count} pending" if pending_count > 0  
60 
61           if failure_count == 0
62             if pending_count > 0
63               @output.puts yellow(summary)
64             else
65               @output.puts green(summary)
66             end
67           else
68             @output.puts red(summary)
69           end
70           @output.flush
71         end
72 
73         def dump_pending
74           unless @pending_examples.empty?
75             @output.puts
76             @output.puts "Pending:"
77             @pending_examples.each do |pending_example|
78               @output.puts "\n#{pending_example[0]} (#{pending_example[1]})"
79               @output.puts "#{pending_example[2]}\n"
80             end
81           end
82           @output.flush
83         end
84         
85         def close
86           @output.close  if (IO === @output) & (@output != $stdout)
87         end
88         
89         def format_backtrace(backtrace)
90           return "" if backtrace.nil?
91           backtrace.map { |line| backtrace_line(line) }.join("\n")
92         end
93       
94       protected
95 
96         def colour?
97           !!@options.colour
98         end
99 
100         def dry_run?
101           !!@options.dry_run
102         end
103         
104         def autospec?
105           !!@options.autospec || ENV.has_key?("AUTOTEST")
106         end
107         
108         def backtrace_line(line)
109           line.sub(/\A([^:]+:\d+)$/, '\\1:')
110         end
111 
112         def colour(text, colour_code)
113           return text if output_to_file?
114           return text unless ENV['RSPEC_COLOR'] || (colour? & (autospec? || output_to_tty?)) 
115           "#{colour_code}#{text}\e[0m"
116         end
117 
118         def output_to_file?
119           File === @output
120         end
121         
122         def output_to_tty?
123           begin
124             @output.tty?
125           rescue NoMethodError
126             false
127           end
128         end
129         
130         def green(text); colour(text, "\e[32m"); end
131         def red(text); colour(text, "\e[31m"); end
132         def yellow(text); colour(text, "\e[33m"); end
133         def blue(text); colour(text, "\e[34m"); end
134         
135         def magenta(text)
136           Spec::deprecate("BaseTextFormatter#magenta")
137           red(text)
138         end
139       end
140     end
141   end
142 end

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