Name | Total Lines | Lines of Code | Total Coverage | Code Coverage |
---|---|---|---|---|
rcov/ruby/1.8/gems/rspec-expectations-2.5.0/lib/rspec/matchers/extensions/instance_exec.rb | 31 | 24 | 12.90%
|
16.67%
|
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 module RSpec |
2 module Matchers |
3 module InstanceExec |
4 unless respond_to?(:instance_exec) |
5 # based on Bounded Spec InstanceExec (Mauricio Fernandez) |
6 # http://eigenclass.org/hiki/bounded+space+instance_exec |
7 # - uses singleton_class of matcher instead of global |
8 # InstanceExecHelper module |
9 # - this keeps it scoped to this class only, which is the |
10 # only place we need it |
11 # - only necessary for ruby 1.8.6 |
12 def instance_exec(*args, &block) |
13 singleton_class = (class << self; self; end) |
14 begin |
15 orig_critical, Thread.critical = Thread.critical, true |
16 n = 0 |
17 n += 1 while respond_to?(method_name="__instance_exec#{n}") |
18 singleton_class.module_eval{ define_method(method_name, &block) } |
19 ensure |
20 Thread.critical = orig_critical |
21 end |
22 begin |
23 return send(method_name, *args) |
24 ensure |
25 singleton_class.module_eval{ remove_method(method_name) } rescue nil |
26 end |
27 end |
28 end |
29 end |
30 end |
31 end |
Generated on Fri Apr 22 17:22:41 -0700 2011 with rcov 0.9.8