Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Commit 97e1fb4

Browse files
committed
Merge pull request #1337 from alexander-clark/master
documentation for RSpec::Core::World
2 parents 508f93b + a90b3c7 commit 97e1fb4

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

lib/rspec/core/world.rb

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
module RSpec
22
module Core
3+
# @api private
4+
#
5+
# Internal container for global non-configuration data
36
class World
47

58
include RSpec::Core::Hooks
@@ -20,52 +23,85 @@ def initialize(configuration=RSpec.configuration)
2023
}
2124
end
2225

26+
# @api private
27+
#
28+
# Apply ordering strategy from configuration to example groups
2329
def ordered_example_groups
2430
ordering_strategy = @configuration.ordering_registry.fetch(:global)
2531
ordering_strategy.order(@example_groups)
2632
end
2733

34+
# @api private
35+
#
36+
# Reset world to 'scratch' before running suite
2837
def reset
2938
example_groups.clear
3039
SharedExampleGroup.registry.clear
3140
end
3241

42+
# @api private
43+
#
44+
# Get current filter manager
3345
def filter_manager
3446
@configuration.filter_manager
3547
end
3648

49+
# @api private
50+
#
51+
# Register an example group
3752
def register(example_group)
3853
example_groups << example_group
3954
example_group
4055
end
4156

57+
# @api private
58+
#
59+
# Get inclusion filter
4260
def inclusion_filter
4361
@configuration.inclusion_filter
4462
end
4563

64+
# @api private
65+
#
66+
# Get exclusion filter
4667
def exclusion_filter
4768
@configuration.exclusion_filter
4869
end
4970

71+
# @api private
72+
#
73+
# Set the current config on a group
5074
def configure_group(group)
5175
@configuration.configure_group(group)
5276
end
5377

78+
# @api private
79+
#
80+
# Get count of examples to be run
5481
def example_count
5582
FlatMap.flat_map(example_groups) {|g| g.descendants}.
5683
inject(0) {|sum, g| sum + g.filtered_examples.size}
5784
end
5885

86+
# @api private
87+
#
88+
# Find line number of previous declaration
5989
def preceding_declaration_line(filter_line)
6090
declaration_line_numbers.sort.inject(nil) do |highest_prior_declaration_line, line|
6191
line <= filter_line ? line : highest_prior_declaration_line
6292
end
6393
end
6494

95+
# @api private
96+
#
97+
# Get reporter instance
6598
def reporter
6699
@configuration.reporter
67100
end
68101

102+
# @api private
103+
#
104+
# Notify reporter of filters
69105
def announce_filters
70106
filter_announcements = []
71107

@@ -102,16 +138,23 @@ def announce_filters
102138
end
103139
end
104140

141+
# @api private
105142
def everything_filtered_message
106143
"\nAll examples were filtered out"
107144
end
108145

146+
# @api private
147+
#
148+
# Add inclusion filters to announcement message
109149
def announce_inclusion_filter(announcements)
110150
unless inclusion_filter.empty?
111151
announcements << "include #{inclusion_filter.description}"
112152
end
113153
end
114154

155+
# @api private
156+
#
157+
# Add exclusion filters to announcement message
115158
def announce_exclusion_filter(announcements)
116159
unless exclusion_filter.empty_without_conditional_filters?
117160
announcements << "exclude #{exclusion_filter.description}"

0 commit comments

Comments
 (0)