Skip to content

Instantly share code, notes, and snippets.

@fidothe
Created June 26, 2015 18:33
Show Gist options
  • Save fidothe/665b54163c0a3d69ca72 to your computer and use it in GitHub Desktop.
Save fidothe/665b54163c0a3d69ca72 to your computer and use it in GitHub Desktop.
dowsing for spec ordering issues
# encoding: utf-8
SEED = 6514
BASE_CMD = "bundle exec rspec --fail-fast --seed #{SEED}"
all_potential_files = Dir['spec/controllers/**/*_spec.rb', 'spec/features/**/*_spec.rb']
definitely_involved = ['spec/controllers/concerns/x.rb', 'spec/features/y.rb']
potential_files = all_potential_files.to_a - definitely_involved
def attempt(files)
cmd = ([BASE_CMD] + files).join(" ")
puts "\e[32mTrying #{cmd}\e[0m"
success = system(cmd)
unless success
puts "Failed: with \n #{files.join("\n ")}"
raise "Found it!"
end
end
# try one file at a time
(0...potential_files.length).each do |i|
files = definitely_involved + [potential_files[i]]
attempt(files)
end
# try adding one file at a time
(0...potential_files.length).each do |i|
files = definitely_involved + potential_files[0..i]
attempt(files)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment