1
1
module RSpec
2
2
module Core
3
+ # @api private
4
+ #
5
+ # Internal container for global non-configuration data
3
6
class World
4
7
5
8
include RSpec ::Core ::Hooks
@@ -20,52 +23,85 @@ def initialize(configuration=RSpec.configuration)
20
23
}
21
24
end
22
25
26
+ # @api private
27
+ #
28
+ # Apply ordering strategy from configuration to example groups
23
29
def ordered_example_groups
24
30
ordering_strategy = @configuration . ordering_registry . fetch ( :global )
25
31
ordering_strategy . order ( @example_groups )
26
32
end
27
33
34
+ # @api private
35
+ #
36
+ # Reset world to 'scratch' before running suite
28
37
def reset
29
38
example_groups . clear
30
39
SharedExampleGroup . registry . clear
31
40
end
32
41
42
+ # @api private
43
+ #
44
+ # Get current filter manager
33
45
def filter_manager
34
46
@configuration . filter_manager
35
47
end
36
48
49
+ # @api private
50
+ #
51
+ # Register an example group
37
52
def register ( example_group )
38
53
example_groups << example_group
39
54
example_group
40
55
end
41
56
57
+ # @api private
58
+ #
59
+ # Get inclusion filter
42
60
def inclusion_filter
43
61
@configuration . inclusion_filter
44
62
end
45
63
64
+ # @api private
65
+ #
66
+ # Get exclusion filter
46
67
def exclusion_filter
47
68
@configuration . exclusion_filter
48
69
end
49
70
71
+ # @api private
72
+ #
73
+ # Set the current config on a group
50
74
def configure_group ( group )
51
75
@configuration . configure_group ( group )
52
76
end
53
77
78
+ # @api private
79
+ #
80
+ # Get count of examples to be run
54
81
def example_count
55
82
FlatMap . flat_map ( example_groups ) { |g | g . descendants } .
56
83
inject ( 0 ) { |sum , g | sum + g . filtered_examples . size }
57
84
end
58
85
86
+ # @api private
87
+ #
88
+ # Find line number of previous declaration
59
89
def preceding_declaration_line ( filter_line )
60
90
declaration_line_numbers . sort . inject ( nil ) do |highest_prior_declaration_line , line |
61
91
line <= filter_line ? line : highest_prior_declaration_line
62
92
end
63
93
end
64
94
95
+ # @api private
96
+ #
97
+ # Get reporter instance
65
98
def reporter
66
99
@configuration . reporter
67
100
end
68
101
102
+ # @api private
103
+ #
104
+ # Notify reporter of filters
69
105
def announce_filters
70
106
filter_announcements = [ ]
71
107
@@ -102,16 +138,23 @@ def announce_filters
102
138
end
103
139
end
104
140
141
+ # @api private
105
142
def everything_filtered_message
106
143
"\n All examples were filtered out"
107
144
end
108
145
146
+ # @api private
147
+ #
148
+ # Add inclusion filters to announcement message
109
149
def announce_inclusion_filter ( announcements )
110
150
unless inclusion_filter . empty?
111
151
announcements << "include #{ inclusion_filter . description } "
112
152
end
113
153
end
114
154
155
+ # @api private
156
+ #
157
+ # Add exclusion filters to announcement message
115
158
def announce_exclusion_filter ( announcements )
116
159
unless exclusion_filter . empty_without_conditional_filters?
117
160
announcements << "exclude #{ exclusion_filter . description } "
0 commit comments