diff --git a/lib/rspec/core.rb b/lib/rspec/core.rb index aecbecfe01..3c1e489649 100644 --- a/lib/rspec/core.rb +++ b/lib/rspec/core.rb @@ -12,7 +12,6 @@ warnings set - flat_map filter_manager dsl notifications diff --git a/lib/rspec/core/configuration.rb b/lib/rspec/core/configuration.rb index 15f3dee4a2..5d98a4b87d 100644 --- a/lib/rspec/core/configuration.rb +++ b/lib/rspec/core/configuration.rb @@ -2154,7 +2154,7 @@ def run_suite_hooks(hook_description, hooks) end def get_files_to_run(paths) - files = FlatMap.flat_map(paths_to_check(paths)) do |path| + files = paths_to_check(paths).flat_map do |path| path = path.gsub(File::ALT_SEPARATOR, File::SEPARATOR) if File::ALT_SEPARATOR File.directory?(path) ? gather_directories(path) : extract_location(path) end.uniq diff --git a/lib/rspec/core/configuration_options.rb b/lib/rspec/core/configuration_options.rb index f669cda5f9..4e74719eb6 100644 --- a/lib/rspec/core/configuration_options.rb +++ b/lib/rspec/core/configuration_options.rb @@ -169,7 +169,7 @@ def parse_args_ignoring_files_or_dirs_to_run(args, source) def args_from_options_file(path) return [] unless path && File.exist?(path) config_string = options_file_as_erb_string(path) - FlatMap.flat_map(config_string.split(/\n+/), &:shellsplit) + config_string.split(/\n+/).flat_map(&:shellsplit) end def options_file_as_erb_string(path) diff --git a/lib/rspec/core/example_group.rb b/lib/rspec/core/example_group.rb index 1f4f4b07dc..766395797f 100644 --- a/lib/rspec/core/example_group.rb +++ b/lib/rspec/core/example_group.rb @@ -459,7 +459,7 @@ def self.filtered_examples # @private def self.descendant_filtered_examples @descendant_filtered_examples ||= filtered_examples + - FlatMap.flat_map(children, &:descendant_filtered_examples) + children.flat_map(&:descendant_filtered_examples) end # @private @@ -501,7 +501,7 @@ def self.next_runnable_index_for(file) # @private def self.descendants - @_descendants ||= [self] + FlatMap.flat_map(children, &:descendants) + @_descendants ||= [self] + children.flat_map(&:descendants) end ## @private @@ -646,7 +646,7 @@ def self.for_filtered_examples(reporter, &block) def self.declaration_locations @declaration_locations ||= [Metadata.location_tuple_from(metadata)] + examples.map { |e| Metadata.location_tuple_from(e.metadata) } + - FlatMap.flat_map(children, &:declaration_locations) + children.flat_map(&:declaration_locations) end # @return [String] the unique id of this example group. Pass diff --git a/lib/rspec/core/flat_map.rb b/lib/rspec/core/flat_map.rb deleted file mode 100644 index dd294ae84d..0000000000 --- a/lib/rspec/core/flat_map.rb +++ /dev/null @@ -1,12 +0,0 @@ -module RSpec - module Core - # @private - module FlatMap - def flat_map(array, &block) - array.flat_map(&block) - end - - module_function :flat_map - end - end -end diff --git a/lib/rspec/core/formatters/exception_presenter.rb b/lib/rspec/core/formatters/exception_presenter.rb index 062b14f8fe..6ebc420d4a 100644 --- a/lib/rspec/core/formatters/exception_presenter.rb +++ b/lib/rspec/core/formatters/exception_presenter.rb @@ -334,7 +334,7 @@ def sub_failure_list_formatter(exception, message_color) common_backtrace_truncater = CommonBacktraceTruncater.new(exception) lambda do |failure_number, colorizer| - FlatMap.flat_map(exception.all_exceptions.each_with_index) do |failure, index| + exception.all_exceptions.each_with_index.flat_map do |failure, index| options = with_multiple_error_options_as_needed( failure, :description => nil, diff --git a/lib/rspec/core/formatters/snippet_extractor.rb b/lib/rspec/core/formatters/snippet_extractor.rb index 6b7102de81..caee4d4dce 100644 --- a/lib/rspec/core/formatters/snippet_extractor.rb +++ b/lib/rspec/core/formatters/snippet_extractor.rb @@ -70,7 +70,7 @@ def line_range_of_expression end def unclosed_tokens_in_line_range(line_range) - tokens = FlatMap.flat_map(line_range) do |line_number| + tokens = line_range.flat_map do |line_number| source.tokens_by_line_number[line_number] end diff --git a/lib/rspec/core/hooks.rb b/lib/rspec/core/hooks.rb index 8d1ea5f5ec..d69e2fe63f 100644 --- a/lib/rspec/core/hooks.rb +++ b/lib/rspec/core/hooks.rb @@ -564,7 +564,7 @@ def process(host, parent_groups, globals, position, scope) hooks_to_process = globals.processable_hooks_for(position, scope, host) return if hooks_to_process.empty? - hooks_to_process -= FlatMap.flat_map(parent_groups) do |group| + hooks_to_process -= parent_groups.flat_map do |group| group.hooks.all_hooks_for(position, scope) end return if hooks_to_process.empty? @@ -609,7 +609,7 @@ def run_example_hooks_for(example, position, each_method) end def run_around_example_hooks_for(example) - hooks = FlatMap.flat_map(owner_parent_groups) do |group| + hooks = owner_parent_groups.flat_map do |group| group.hooks.matching_hooks_for(:around, :example, example) end diff --git a/lib/rspec/core/world.rb b/lib/rspec/core/world.rb index 108af900a6..d4b338ea93 100644 --- a/lib/rspec/core/world.rb +++ b/lib/rspec/core/world.rb @@ -99,18 +99,18 @@ def exclusion_filter # # Get count of examples to be run. def example_count(groups=example_groups) - FlatMap.flat_map(groups) { |g| g.descendants }. + groups.flat_map { |g| g.descendants }. inject(0) { |a, e| a + e.filtered_examples.size } end # @private def all_example_groups - FlatMap.flat_map(example_groups) { |g| g.descendants } + example_groups.flat_map { |g| g.descendants } end # @private def all_examples - FlatMap.flat_map(all_example_groups) { |g| g.examples } + all_example_groups.flat_map { |g| g.examples } end # @private @@ -223,7 +223,7 @@ def announce_exclusion_filter(announcements) def descending_declaration_line_numbers_by_file @descending_declaration_line_numbers_by_file ||= begin - declaration_locations = FlatMap.flat_map(example_groups, &:declaration_locations) + declaration_locations = example_groups.flat_map(&:declaration_locations) declarations_by_file = declaration_locations.group_by(&:first) # by file name diff --git a/spec/rspec/core/configuration_spec.rb b/spec/rspec/core/configuration_spec.rb index e49aafd615..4b0207e8e1 100644 --- a/spec/rspec/core/configuration_spec.rb +++ b/spec/rspec/core/configuration_spec.rb @@ -1982,7 +1982,7 @@ def exclude?(line) registered_examples = nil RSpec.configuration.define_derived_metadata(:ex) do |_meta| - registered_examples = FlatMap.flat_map(RSpec.world.all_example_groups, &:examples) + registered_examples = RSpec.world.all_example_groups.flat_map(&:examples) end example = nil