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/spec/dsl/example.rb 135 110
100.0% 
100.0% 
  1 require 'timeout'
  2 
  3 module Spec
  4   module DSL
  5     class Example
  6       # The global sequence number of this example
  7       attr_accessor :number
  8       
  9       def initialize(description, options={}, &example_block)
 10         @from = caller(0)[3]
 11         @options = options
 12         @example_block = example_block
 13         @description = description
 14         @description_generated_proc = lambda { |desc| @generated_description = desc }
 15       end
 16       
 17       def run(reporter, before_each_block, after_each_block, dry_run, execution_context, timeout=nil)
 18         @dry_run = dry_run
 19         reporter.example_started(self)
 20         return reporter.example_finished(self) if dry_run
 21 
 22         errors = []
 23         location = nil
 24         Timeout.timeout(timeout) do
 25           before_each_ok = before_example(execution_context, errors, &before_each_block)
 26           example_ok = run_example(execution_context, errors) if before_each_ok
 27           after_each_ok = after_example(execution_context, errors, &after_each_block)
 28           location = failure_location(before_each_ok, example_ok, after_each_ok)
 29         end
 30 
 31         ExampleShouldRaiseHandler.new(@from, @options).handle(errors)
 32         reporter.example_finished(self, errors.first, location, @example_block.nil?) if reporter
 33       end
 34       
 35       def matches?(matcher, specified_examples)
 36         matcher.example_desc = description
 37         matcher.matches?(specified_examples)
 38       end
 39       
 40       def description
 41         @description == :__generate_description ? generated_description : @description
 42       end
 43       
 44       def to_s
 45         description
 46       end
 47 
 48     private
 49       
 50       def generated_description
 51         return @generated_description if @generated_description
 52         if @dry_run
 53           "NO NAME (Because of --dry-run)"
 54         else
 55           if @failed
 56             "NO NAME (Because of Error raised in matcher)"
 57           else
 58             "NO NAME (Because there were no expectations)"
 59           end
 60         end
 61       end
 62       
 63       def before_example(execution_context, errors, &behaviour_before_block)
 64         setup_mocks(execution_context)
 65         Spec::Matchers.description_generated(@description_generated_proc)
 66         
 67         builder = CompositeProcBuilder.new
 68         before_proc = builder.proc(&append_errors(errors))
 69         execution_context.instance_eval(&before_proc)
 70         
 71         execution_context.instance_eval(&behaviour_before_block) if behaviour_before_block
 72         return errors.empty?
 73       rescue Exception => e
 74         @failed = true
 75         errors << e
 76         return false
 77       end
 78 
 79       def run_example(execution_context, errors)
 80         begin
 81           execution_context.instance_eval(&@example_block) if @example_block
 82           return true
 83         rescue Exception => e
 84           @failed = true
 85           errors << e
 86           return false
 87         end
 88       end
 89 
 90       def after_example(execution_context, errors, &behaviour_after_each)
 91         execution_context.instance_eval(&behaviour_after_each) if behaviour_after_each
 92 
 93         begin
 94           verify_mocks(execution_context)
 95         ensure
 96           teardown_mocks(execution_context)
 97         end
 98 
 99         Spec::Matchers.unregister_description_generated(@description_generated_proc)
100 
101         builder = CompositeProcBuilder.new
102         after_proc = builder.proc(&append_errors(errors))
103         execution_context.instance_eval(&after_proc)
104 
105         return errors.empty?
106       rescue Exception => e
107         @failed = true
108         errors << e
109         return false
110       end
111       
112       def setup_mocks(execution_context)
113         execution_context.setup_mocks_for_rspec if execution_context.respond_to?(:setup_mocks_for_rspec)
114       end
115       
116       def verify_mocks(execution_context)
117         execution_context.verify_mocks_for_rspec if execution_context.respond_to?(:verify_mocks_for_rspec)
118       end
119       
120       def teardown_mocks(execution_context)
121         execution_context.teardown_mocks_for_rspec if execution_context.respond_to?(:teardown_mocks_for_rspec)
122       end
123       
124       def append_errors(errors)
125         proc {|error| errors << error}
126       end
127       
128       def failure_location(before_each_ok, example_ok, after_each_ok)
129         return 'before(:each)' unless before_each_ok
130         return description unless example_ok
131         return 'after(:each)' unless after_each_ok
132       end
133     end
134   end
135 end

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

Valid XHTML 1.0! Valid CSS!