Class: RSpec::Core::World Private
- Inherits:
-
Object
- Object
- RSpec::Core::World
- Includes:
- Hooks
- Defined in:
- lib/rspec/core/world.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Internal container for global non-configuration data
Constant Summary
Instance Attribute Summary (collapse)
-
- (void) wants_to_quit
private
Used internally to determine what to do when a SIGINT is received.
Instance Method Summary (collapse)
-
- (void) announce_exclusion_filter(announcements)
private
Add exclusion filters to announcement message.
-
- (void) announce_filters
private
Notify reporter of filters.
-
- (void) announce_inclusion_filter(announcements)
private
Add inclusion filters to announcement message.
-
- (void) example_count(groups = example_groups)
private
Get count of examples to be run.
-
- (World) initialize(configuration = RSpec.configuration)
constructor
private
A new instance of World.
-
- (void) ordered_example_groups
private
Apply ordering strategy from configuration to example groups.
-
- (void) preceding_declaration_line(filter_line)
private
Find line number of previous declaration.
-
- (void) register(example_group)
private
Register an example group.
-
- (void) reset
private
Reset world to 'scratch' before running suite.
Methods included from Hooks
#after, #append_after, #around, #before, #prepend_before
Constructor Details
- (World) initialize(configuration = RSpec.configuration)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of World
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/rspec/core/world.rb', line 16 def initialize(configuration=RSpec.configuration) @configuration = configuration @example_groups = [] @filtered_examples = Hash.new { |hash,group| hash[group] = begin examples = group.examples.dup examples = filter_manager.prune(examples) examples.uniq! examples end } end |
Instance Attribute Details
- (void) wants_to_quit
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Used internally to determine what to do when a SIGINT is received
14 15 16 |
# File 'lib/rspec/core/world.rb', line 14 def wants_to_quit @wants_to_quit end |
Instance Method Details
- (void) announce_exclusion_filter(announcements)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Add exclusion filters to announcement message
167 168 169 170 171 |
# File 'lib/rspec/core/world.rb', line 167 def announce_exclusion_filter(announcements) unless exclusion_filter.empty? announcements << "exclude #{exclusion_filter.description}" end end |
- (void) announce_filters
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Notify reporter of filters
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/rspec/core/world.rb', line 114 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.("Run options: #{filter_announcements[0]}") else reporter.("Run options:\n #{filter_announcements.join("\n ")}") end end if @configuration.run_all_when_everything_filtered? && example_count.zero? reporter.("#{}; ignoring #{inclusion_filter.description}") filtered_examples.clear inclusion_filter.clear end if example_count.zero? example_groups.clear if filter_manager.empty? reporter.("No examples found.") elsif exclusion_filter.empty? = if @configuration.run_all_when_everything_filtered? << "; ignoring #{inclusion_filter.description}" end reporter.() elsif inclusion_filter.empty? reporter.() end end end |
- (void) announce_inclusion_filter(announcements)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Add inclusion filters to announcement message
158 159 160 161 162 |
# File 'lib/rspec/core/world.rb', line 158 def announce_inclusion_filter(announcements) unless inclusion_filter.empty? announcements << "include #{inclusion_filter.description}" end end |
- (void) example_count(groups = example_groups)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Get count of examples to be run
92 93 94 95 |
# File 'lib/rspec/core/world.rb', line 92 def example_count(groups=example_groups) FlatMap.flat_map(groups) {|g| g.descendants}. inject(0) {|sum, g| sum + g.filtered_examples.size} end |
- (void) ordered_example_groups
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Apply ordering strategy from configuration to example groups
43 44 45 46 |
# File 'lib/rspec/core/world.rb', line 43 def ordered_example_groups ordering_strategy = @configuration.ordering_registry.fetch(:global) ordering_strategy.order(@example_groups) end |
- (void) preceding_declaration_line(filter_line)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Find line number of previous declaration
100 101 102 103 104 |
# File 'lib/rspec/core/world.rb', line 100 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 |
- (void) register(example_group)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Register an example group
64 65 66 67 |
# File 'lib/rspec/core/world.rb', line 64 def register(example_group) example_groups << example_group example_group end |
- (void) reset
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Reset world to 'scratch' before running suite
51 52 53 54 |
# File 'lib/rspec/core/world.rb', line 51 def reset example_groups.clear @shared_example_group_registry = nil end |