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

Customized ordering strategy for running specs #547

@owenthereal

Description

@owenthereal

I noticed that spec can be run in random order (https://github.com/rspec/rspec-core/blob/master/lib/rspec/core/extensions/ordered.rb#L12-13). Would it make sense to provide an extension point to run spec in customized order?

Here are some sudo codes:

# spec_helper.rb
RSpec.configure do |config|
  config.order_strategy = lambda {
    ...
  }
end

module RSpec
  module Core
    # @private
    module Extensions
      # @private
      # Used to extend lists of examples and groups to support ordering
      # strategies like randomization.
      module Ordered
        # @private
        def ordered
          if RSpec.configuration.randomize?
            Kernel.srand RSpec.configuration.seed
            sort_by { Kernel.rand size }
          elsif !RSpec.configuration.order_strategy.nil?
            sort_by { RSpec.configuration.order_stategy }
          else
            self
          end
        end
      end
    end
  end
end

It would be nice if I could define what order my specs are run to maximize the feedback loop (e.g., more important spec runs first)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions