C0 code coverage information
Generated on Wed Dec 24 11:03:27 -0600 2008 with rcov 0.8.1.2
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 class Test::Unit::TestCase
2 class << self
3 attr_accessor :before_each_callbacks, :before_all_callbacks, :after_each_callbacks, :after_all_callbacks
4
5 # Add logic to run before the tests (i.e., a +setup+ method)
6 #
7 # before do
8 # @user = User.first
9 # end
10 #
11 def before(period = :each, &block)
12 send("before_#{period}_callbacks") << block
13 end
14
15 # Add logic to run after the tests (i.e., a +teardown+ method)
16 #
17 # after do
18 # User.delete_all
19 # end
20 #
21 def after(period = :each, &block)
22 send("after_#{period}_callbacks") << block
23 end
24
25 def gather_callbacks(callback_type, period) # :nodoc:
26 callbacks = superclass.respond_to?(:gather_callbacks) ? superclass.gather_callbacks(callback_type, period) : []
27 callbacks.push(*send("#{callback_type}_#{period}_callbacks"))
28 end
29 end
30
31 self.before_all_callbacks = []
32 self.before_each_callbacks = []
33 self.after_each_callbacks = []
34 self.after_all_callbacks = []
35
36 def self.inherited(child) # :nodoc:
37 super
38 child.before_all_callbacks = []
39 child.before_each_callbacks = []
40 child.after_each_callbacks = []
41 child.after_all_callbacks = []
42
43 child.class_eval do
44 def setup
45 super
46 run_each_callbacks :before
47 end
48
49 def teardown
50 super
51 run_each_callbacks :after
52 end
53 end
54 end
55
56 def run_each_callbacks(callback_type) # :nodoc:
57 self.class.gather_callbacks(callback_type, :each).each { |c| instance_eval(&c) }
58 end
59
60 def run_all_callbacks(callback_type) # :nodoc:
61 previous_ivars = instance_variables
62 self.class.gather_callbacks(callback_type, :all).each { |c| instance_eval(&c) }
63 (instance_variables - previous_ivars).inject({}) do |hash, ivar|
64 hash.update ivar => instance_variable_get(ivar)
65 end
66 end
67
68 def set_values_from_callbacks(values) # :nodoc:
69 values.each do |name, value|
70 instance_variable_set name, value
71 end
72 end
73 end
Generated using the rcov code coverage analysis tool for Ruby
version 0.8.1.2.