Module: Mutineer::TestRunners::RSpec::FileOrder
- Defined in:
- lib/mutineer/test_runners/rspec.rb
Overview
Prepended on RSpec::Core::World: a stable sort of the ordered
top-level groups by their file's position. Does nothing without a rank.
Class Attribute Summary collapse
-
.rank ⇒ Hash{String => Integer}?
Each spec file's position, keyed by absolute path, or nil.
Instance Method Summary collapse
-
#ordered_example_groups ⇒ Array<RSpec::Core::ExampleGroup>
The groups RSpec ordered, sorted by file position.
Class Attribute Details
.rank ⇒ Hash{String => Integer}?
Each spec file's position, keyed by absolute path, or nil.
181 182 183 |
# File 'lib/mutineer/test_runners/rspec.rb', line 181 def rank @rank end |
Instance Method Details
#ordered_example_groups ⇒ Array<RSpec::Core::ExampleGroup>
The groups RSpec ordered, sorted by file position.
187 188 189 190 191 192 193 194 195 196 |
# File 'lib/mutineer/test_runners/rspec.rb', line 187 def ordered_example_groups groups = super rank = FileOrder.rank return groups unless rank groups.sort_by.with_index do |group, i| file = group.[:absolute_file_path] || File.(group.file_path) [rank.fetch(file, rank.size), i] end end |