Name | Total Lines | Lines of Code | Total Coverage | Code Coverage |
---|---|---|---|---|
rcov/ruby/1.8/gems/rspec-core-2.5.1/lib/rspec/core/shared_example_group.rb | 53 | 40 | 37.74%
|
30.00%
|
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 Core |
3 module SharedExampleGroup |
4 |
5 def share_examples_for(name, &block) |
6 ensure_shared_example_group_name_not_taken(name) |
7 RSpec.world.shared_example_groups[name] = block |
8 end |
9 |
10 alias :shared_examples_for :share_examples_for |
11 |
12 def share_as(name, &block) |
13 if Object.const_defined?(name) |
14 mod = Object.const_get(name) |
15 raise_name_error unless mod.created_from_caller(caller) |
16 end |
17 |
18 mod = Module.new do |
19 @shared_block = block |
20 @caller_line = caller.last |
21 |
22 def self.created_from_caller(other_caller) |
23 @caller_line == other_caller.last |
24 end |
25 |
26 def self.included(kls) |
27 kls.describe(&@shared_block) |
28 kls.children.first.metadata[:shared_group_name] = name |
29 end |
30 end |
31 |
32 shared_const = Object.const_set(name, mod) |
33 RSpec.world.shared_example_groups[shared_const] = block |
34 end |
35 |
36 |
37 private |
38 |
39 def raise_name_error |
40 raise NameError, "The first argument (#{name}) to share_as must be a legal name for a constant not already in use." |
41 end |
42 |
43 def ensure_shared_example_group_name_not_taken(name) |
44 if RSpec.world.shared_example_groups.has_key?(name) |
45 raise ArgumentError.new("Shared example group '#{name}' already exists") |
46 end |
47 end |
48 |
49 end |
50 end |
51 end |
52 |
53 include RSpec::Core::SharedExampleGroup |
Generated on Fri Apr 22 17:22:41 -0700 2011 with rcov 0.9.8