Class: RSpec::Core::World
- Inherits:
-
Object
- Object
- RSpec::Core::World
show all
- Includes:
- Hooks
- Defined in:
- lib/rspec/core/world.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Hooks
#after, #append_after, #around, #before, #prepend_before
Constructor Details
#initialize(configuration = RSpec.configuration) ⇒ World
Returns a new instance of World.
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/rspec/core/world.rb', line 10
def initialize(configuration=RSpec.configuration)
@configuration = configuration
@example_groups = [].extend(Extensions::Ordered::ExampleGroups)
@filtered_examples = Hash.new { |hash,group|
hash[group] = begin
examples = group.examples.dup
examples = filter_manager.prune(examples)
examples.uniq
examples.extend(Extensions::Ordered::Examples)
end
}
end
|
Instance Attribute Details
#example_groups ⇒ Object
Returns the value of attribute example_groups.
7
8
9
|
# File 'lib/rspec/core/world.rb', line 7
def example_groups
@example_groups
end
|
#filtered_examples ⇒ Object
Returns the value of attribute filtered_examples.
7
8
9
|
# File 'lib/rspec/core/world.rb', line 7
def filtered_examples
@filtered_examples
end
|
#wants_to_quit ⇒ Object
Returns the value of attribute wants_to_quit.
8
9
10
|
# File 'lib/rspec/core/world.rb', line 8
def wants_to_quit
@wants_to_quit
end
|
Instance Method Details
#announce_exclusion_filter(announcements) ⇒ Object
111
112
113
114
115
|
# File 'lib/rspec/core/world.rb', line 111
def announce_exclusion_filter(announcements)
unless exclusion_filter.empty_without_conditional_filters?
announcements << "exclude #{exclusion_filter.description}"
end
end
|
#announce_filters ⇒ Object
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
# File 'lib/rspec/core/world.rb', line 65
def announce_filters
filter_announcements = []
announce_inclusion_filter filter_announcements
announce_exclusion_filter filter_announcements
unless filter_manager.empty?
if filter_announcements.length == 1
reporter.message("Run options: #{filter_announcements[0]}")
else
reporter.message("Run options:\n #{filter_announcements.join("\n ")}")
end
end
if @configuration.run_all_when_everything_filtered? && example_count.zero?
reporter.message("#{everything_filtered_message}; ignoring #{inclusion_filter.description}")
filtered_examples.clear
inclusion_filter.clear
end
if example_count.zero?
example_groups.clear
if filter_manager.empty?
reporter.message("No examples found.")
elsif exclusion_filter.empty_without_conditional_filters?
message = everything_filtered_message
if @configuration.run_all_when_everything_filtered?
message << "; ignoring #{inclusion_filter.description}"
end
reporter.message(message)
elsif inclusion_filter.empty?
reporter.message(everything_filtered_message)
end
end
end
|
#announce_inclusion_filter(announcements) ⇒ Object
105
106
107
108
109
|
# File 'lib/rspec/core/world.rb', line 105
def announce_inclusion_filter(announcements)
unless inclusion_filter.empty?
announcements << "include #{inclusion_filter.description}"
end
end
|
45
46
47
|
# File 'lib/rspec/core/world.rb', line 45
def configure_group(group)
@configuration.configure_group(group)
end
|
#everything_filtered_message ⇒ Object
101
102
103
|
# File 'lib/rspec/core/world.rb', line 101
def everything_filtered_message
"\nAll examples were filtered out"
end
|
#example_count ⇒ Object
49
50
51
52
53
|
# File 'lib/rspec/core/world.rb', line 49
def example_count
example_groups.collect {|g| g.descendants}.flatten.inject(0) do |sum, g|
sum += g.filtered_examples.size
end
end
|
#exclusion_filter ⇒ Object
41
42
43
|
# File 'lib/rspec/core/world.rb', line 41
def exclusion_filter
@configuration.exclusion_filter
end
|
#filter_manager ⇒ Object
28
29
30
|
# File 'lib/rspec/core/world.rb', line 28
def filter_manager
@configuration.filter_manager
end
|
#inclusion_filter ⇒ Object
37
38
39
|
# File 'lib/rspec/core/world.rb', line 37
def inclusion_filter
@configuration.inclusion_filter
end
|
#preceding_declaration_line(filter_line) ⇒ Object
55
56
57
58
59
|
# File 'lib/rspec/core/world.rb', line 55
def preceding_declaration_line(filter_line)
declaration_line_numbers.sort.inject(nil) do |highest_prior_declaration_line, line|
line <= filter_line ? line : highest_prior_declaration_line
end
end
|
#register(example_group) ⇒ Object
32
33
34
35
|
# File 'lib/rspec/core/world.rb', line 32
def register(example_group)
example_groups << example_group
example_group
end
|
#reporter ⇒ Object
61
62
63
|
# File 'lib/rspec/core/world.rb', line 61
def reporter
@configuration.reporter
end
|