C0 code coverage information
Generated on Mon Aug 13 01:18:55 -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.
1 begin
2 require 'rubygems'
3 require 'heckle'
4 rescue LoadError ; raise "You must gem install heckle to use --heckle" ; end
5
6 module Spec
7 module Runner
8 # Creates a new Heckler configured to heckle all methods in the classes
9 # whose name matches +filter+
10 class HeckleRunner
11 def initialize(filter, heckle_class=Heckler)
12 @filter = filter
13 @heckle_class = heckle_class
14 end
15
16 # Runs all the contexts held by +behaviour_runner+ once for each of the
17 # methods in the matched classes.
18 def heckle_with(behaviour_runner)
19 if @filter =~ /(.*)[#\.](.*)/
20 heckle_method($1, $2)
21 else
22 heckle_class_or_module(@filter)
23 end
24 end
25
26 def heckle_method(class_name, method_name)
27 verify_constant(class_name)
28 heckle = @heckle_class.new(class_name, method_name, behaviour_runner)
29 heckle.validate
30 end
31
32 def heckle_class_or_module(class_or_module_name)
33 verify_constant(class_or_module_name)
34 pattern = /^#{class_or_module_name}/
35 classes = []
36 ObjectSpace.each_object(Class) do |klass|
37 classes << klass if klass.name =~ pattern
38 end
39
40 classes.each do |klass|
41 klass.instance_methods(false).each do |method_name|
42 heckle = @heckle_class.new(klass.name, method_name, behaviour_runner)
43 heckle.validate
44 end
45 end
46 end
47
48 def verify_constant(name)
49 begin
50 # This is defined in Heckle
51 name.to_class
52 rescue
53 raise "Heckling failed - \"#{name}\" is not a known class or module"
54 end
55 end
56 end
57
58 #Supports Heckle 1.2 and prior (earlier versions used Heckle::Base)
59 class Heckler < (Heckle.const_defined?(:Base) ? Heckle::Base : Heckle)
60 def initialize(klass_name, method_name, behaviour_runner)
61 super(klass_name, method_name)
62 @behaviour_runner = behaviour_runner
63 end
64
65 def tests_pass?
66 paths = [] # We can pass an empty array of paths - our specs are already loaded.
67 failure_count = @behaviour_runner.run(paths, false)
68 failure_count == 0
69 end
70 end
71 end
72 end
Generated using the rcov code coverage analysis tool for Ruby version 0.8.0.