Created
January 5, 2022 22:11
-
-
Save HarlemSquirrel/5f92c9054c8eecfaa2787e4d63edbe8f to your computer and use it in GitHub Desktop.
Run one or more specs as many times as you need in a row.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
## | |
# Run one or more specs as many times as you need in a row. | |
# | |
# The files are loaded just once for speed and | |
# failure counts are tracked and reported at the end. | |
# | |
# Provide the number of times and the file(s). | |
# i.e. | |
# rspec-repeat 5 spec/models/user_spec.rb:11 | |
# | |
raise("No run count provided") unless ARGV[0] =~ /\A[0-9]+\z/ | |
RUN_COUNT = ARGV[0].to_i | |
require 'bundler/setup' | |
require 'rspec/core' | |
failure_count = 0 | |
puts "🔁 Running specs #{RUN_COUNT} times..." | |
RUN_COUNT.times do | |
# This does not generate a new seed each time but there must be a way to do that if needed. | |
failure_count += RSpec::Core::Runner.run(ARGV[1..]) | |
RSpec.clear_examples | |
end | |
puts "\nDone!", "We had #{failure_count} failures in all." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment