Name | Total Lines | Lines of Code | Total Coverage | Code Coverage |
---|---|---|---|---|
rcov/ruby/1.8/gems/rspec-core-2.5.1/lib/rspec/core/world.rb | 102 | 82 | 70.59%
|
64.63%
|
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 class World |
4 |
5 attr_reader :example_groups, :filtered_examples, :wants_to_quit |
6 attr_writer :wants_to_quit |
7 |
8 def initialize(configuration=RSpec.configuration) |
9 @configuration = configuration |
10 @example_groups = [] |
11 @filtered_examples = Hash.new { |hash,group| |
12 hash[group] = begin |
13 examples = group.examples.dup |
14 examples = apply_exclusion_filters(examples, exclusion_filter) if exclusion_filter |
15 examples = apply_inclusion_filters(examples, inclusion_filter) if inclusion_filter |
16 examples.uniq |
17 end |
18 } |
19 end |
20 |
21 def register(example_group) |
22 example_groups << example_group |
23 example_group |
24 end |
25 |
26 def inclusion_filter |
27 @configuration.filter |
28 end |
29 |
30 def exclusion_filter |
31 @configuration.exclusion_filter |
32 end |
33 |
34 def configure_group(group) |
35 @configuration.configure_group(group) |
36 end |
37 |
38 def shared_example_groups |
39 @shared_example_groups ||= {} |
40 end |
41 |
42 def example_count |
43 example_groups.collect {|g| g.descendants}.flatten.inject(0) { |sum, g| sum += g.filtered_examples.size } |
44 end |
45 |
46 def apply_inclusion_filters(examples, conditions={}) |
47 examples.select(&apply?(:any?, conditions)) |
48 end |
49 |
50 alias_method :find, :apply_inclusion_filters |
51 |
52 def apply_exclusion_filters(examples, conditions={}) |
53 examples.reject(&apply?(:any?, conditions)) |
54 end |
55 |
56 def preceding_declaration_line(filter_line) |
57 declaration_line_numbers.inject(nil) do |highest_prior_declaration_line, line| |
58 line <= filter_line ? line : highest_prior_declaration_line |
59 end |
60 end |
61 |
62 def announce_inclusion_filter |
63 if inclusion_filter |
64 if @configuration.run_all_when_everything_filtered? && RSpec.world.example_count.zero? |
65 @configuration.reporter.message "No examples were matched by #{inclusion_filter.inspect}, running all" |
66 @configuration.clear_inclusion_filter |
67 filtered_examples.clear |
68 else |
69 @configuration.reporter.message "Run filtered using #{inclusion_filter.inspect}" |
70 end |
71 end |
72 end |
73 |
74 def announce_exclusion_filter |
75 if exclusion_filter && RSpec.world.example_count.zero? |
76 @configuration.reporter.message( |
77 "No examples were matched. Perhaps #{exclusion_filter.inspect} is excluding everything?") |
78 example_groups.clear |
79 end |
80 end |
81 |
82 include RSpec::Core::Hooks |
83 |
84 def find_hook(hook, scope, group, example = nil) |
85 @configuration.find_hook(hook, scope, group, example) |
86 end |
87 |
88 private |
89 |
90 def apply?(predicate, conditions) |
91 lambda {|example| example.metadata.apply?(predicate, conditions)} |
92 end |
93 |
94 def declaration_line_numbers |
95 @line_numbers ||= example_groups.inject([]) do |lines, g| |
96 lines + g.declaration_line_numbers |
97 end |
98 end |
99 |
100 end |
101 end |
102 end |
Generated on Fri Apr 22 17:22:42 -0700 2011 with rcov 0.9.8