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/behaviour_eval.rb 231 144
100.0% 
100.0% 
  1 module Spec
  2   module DSL
  3     module BehaviourEval
  4       module ModuleMethods
  5         include BehaviourCallbacks
  6 
  7         attr_writer :behaviour
  8         attr_accessor :description
  9 
 10         # RSpec runs every example in a new instance of Object, mixing in
 11         # the behaviour necessary to run examples. Because this behaviour gets
 12         # mixed in, it can get mixed in to an instance of any class at all.
 13         #
 14         # This is something that you would hardly ever use, but there is one
 15         # common use case for it - inheriting from Test::Unit::TestCase. RSpec's
 16         # Rails plugin uses this feature to provide access to all of the features
 17         # that are available for Test::Unit within RSpec examples.
 18         def inherit(klass)
 19           raise ArgumentError.new("Shared behaviours cannot inherit from classes") if @behaviour.shared?
 20           @behaviour_superclass = klass
 21           derive_execution_context_class_from_behaviour_superclass
 22         end
 23 
 24         # You can pass this one or many modules. Each module will subsequently
 25         # be included in the each object in which an example is run. Use this
 26         # to provide global helper methods to your examples.
 27         #
 28         # == Example
 29         #
 30         #   module HelperMethods
 31         #     def helper_method
 32         #       ...
 33         #     end
 34         #   end
 35         #
 36         #   describe Thing do
 37         #     include HelperMethods
 38         #     it "should do stuff" do
 39         #       helper_method
 40         #     end
 41         #   end
 42         def include(*mods)
 43           mods.each do |mod|
 44             included_modules << mod
 45             mod.send :included, self
 46           end
 47         end
 48 
 49         # Use this to pull in examples from shared behaviours.
 50         # See Spec::Runner for information about shared behaviours.
 51         def it_should_behave_like(behaviour_description)
 52           behaviour = @behaviour.class.find_shared_behaviour(behaviour_description)
 53           if behaviour.nil?
 54             raise RuntimeError.new("Shared Behaviour '#{behaviour_description}' can not be found")
 55           end
 56           behaviour.copy_to(self)
 57         end
 58 
 59         def copy_to(eval_module) # :nodoc:
 60           examples.each          { |e| eval_module.examples << e; }
 61           before_each_parts.each { |p| eval_module.before_each_parts << p }
 62           after_each_parts.each  { |p| eval_module.after_each_parts << p }
 63           before_all_parts.each  { |p| eval_module.before_all_parts << p }
 64           after_all_parts.each   { |p| eval_module.after_all_parts << p }
 65           included_modules.each  { |m| eval_module.included_modules << m }
 66           eval_module.included_modules << self
 67         end
 68         
 69         # :call-seq:
 70         #   predicate_matchers[matcher_name] = method_on_object
 71         #   predicate_matchers[matcher_name] = [method1_on_object, method2_on_object]
 72         #
 73         # Dynamically generates a custom matcher that will match
 74         # a predicate on your class. RSpec provides a couple of these
 75         # out of the box:
 76         #
 77         #   exist (or state expectations)
 78         #     File.should exist("path/to/file")
 79         #
 80         #   an_instance_of (for mock argument constraints)
 81         #     mock.should_receive(:message).with(an_instance_of(String))
 82         #
 83         # == Examples
 84         #
 85         #   class Fish
 86         #     def can_swim?
 87         #       true
 88         #     end
 89         #   end
 90         #
 91         #   describe Fish do
 92         #     predicate_matchers[:swim] = :can_swim?
 93         #     it "should swim" do
 94         #       Fish.new.should swim
 95         #     end
 96         #   end
 97         def predicate_matchers
 98           @predicate_matchers ||= {:exist => :exist?, :an_instance_of => :is_a?}
 99         end
100         
101         def define_predicate_matchers(hash=nil) # :nodoc:
102           if hash.nil?
103             define_predicate_matchers(predicate_matchers)
104             define_predicate_matchers(Spec::Runner.configuration.predicate_matchers)
105           else
106             hash.each_pair do |matcher_method, method_on_object|
107               define_method matcher_method do |*args|
108                 eval("be_#{method_on_object.to_s.gsub('?','')}(*args)")
109               end
110             end
111           end
112         end
113         
114         # Creates an instance of Spec::DSL::Example and adds
115         # it to a collection of examples of the current behaviour.
116         def it(description=:__generate_description, opts={}, &block)
117           examples << Example.new(description, opts, &block)
118         end
119         
120         # Alias for it.
121         def specify(description=:__generate_description, opts={}, &block)
122           it(description, opts, &block)
123         end
124 
125         def methods # :nodoc:
126           my_methods = super
127           my_methods |= behaviour_superclass.methods
128           my_methods
129         end
130 
131       protected
132 
133         def method_missing(method_name, *args)
134           if behaviour_superclass.respond_to?(method_name)
135             return execution_context_class.send(method_name, *args)
136           end
137           super
138         end
139 
140         def before_each_proc(behaviour_type, &error_handler)
141           parts = []
142           parts.push(*Behaviour.before_each_parts(nil))
143           parts.push(*Behaviour.before_each_parts(behaviour_type)) unless behaviour_type.nil?
144           parts.push(*before_each_parts(nil))
145           parts.push(*before_each_parts(behaviour_type)) unless behaviour_type.nil?
146           CompositeProcBuilder.new(parts).proc(&error_handler)
147         end
148 
149         def before_all_proc(behaviour_type, &error_handler)
150           parts = []
151           parts.push(*Behaviour.before_all_parts(nil))
152           parts.push(*Behaviour.before_all_parts(behaviour_type)) unless behaviour_type.nil?
153           parts.push(*before_all_parts(nil))
154           parts.push(*before_all_parts(behaviour_type)) unless behaviour_type.nil?
155           CompositeProcBuilder.new(parts).proc(&error_handler)
156         end
157 
158         def after_all_proc(behaviour_type)
159           parts = []
160           parts.push(*after_all_parts(behaviour_type)) unless behaviour_type.nil?
161           parts.push(*after_all_parts(nil))
162           parts.push(*Behaviour.after_all_parts(behaviour_type)) unless behaviour_type.nil?
163           parts.push(*Behaviour.after_all_parts(nil))
164           CompositeProcBuilder.new(parts).proc
165         end
166 
167         def after_each_proc(behaviour_type)
168           parts = []
169           parts.push(*after_each_parts(behaviour_type)) unless behaviour_type.nil?
170           parts.push(*after_each_parts(nil))
171           parts.push(*Behaviour.after_each_parts(behaviour_type)) unless behaviour_type.nil?
172           parts.push(*Behaviour.after_each_parts(nil))
173           CompositeProcBuilder.new(parts).proc
174         end
175 
176       private
177 
178         def execution_context_class
179           @execution_context_class ||= derive_execution_context_class_from_behaviour_superclass
180         end
181 
182         def derive_execution_context_class_from_behaviour_superclass
183           @execution_context_class = Class.new(behaviour_superclass)
184           behaviour_superclass.spec_inherited(self) if behaviour_superclass.respond_to?(:spec_inherited)
185           @execution_context_class
186         end
187 
188         def behaviour_superclass
189           @behaviour_superclass ||= Object
190         end
191 
192         protected
193         def included_modules
194           @included_modules ||= [::Spec::Matchers]
195         end
196 
197         def examples
198           @examples ||= []
199         end
200       end
201 
202       module InstanceMethods
203         def initialize(*args, &block) #:nodoc:
204           # TODO - inheriting from TestUnit::TestCase fails without this
205           # - let's figure out why and move this somewhere else
206         end
207 
208         def violated(message="")
209           raise Spec::Expectations::ExpectationNotMetError.new(message)
210         end
211 
212         def inspect
213           "[RSpec example]"
214         end
215         
216         def pending(message)
217           if block_given?
218             begin
219               yield
220             rescue Exception => e
221               raise Spec::DSL::ExamplePendingError.new(message)
222             end
223             raise Spec::DSL::PendingFixedError.new("Expected pending '#{message}' to fail. No Error was raised.")
224           else
225             raise Spec::DSL::ExamplePendingError.new(message)
226           end
227         end
228       end
229     end
230   end
231 end

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

Valid XHTML 1.0! Valid CSS!