I've noticed a couple specs that are failing intermittently depending on the order they're run.
To isolate them I'm looking for a command where I can enter the seed number and see all the specs listed with line numbers in the order determined by the seed number. Is this possible? using --format=documentation did not provide the info needed.
From there I will note the list of tests run BEFORE the intermittent failure each time it occurs and eventually narrow down to my culprit.
RSpec's JSON formatter outputs the filenames and line numbers in the order they were run:
rspec --seed 1 -f json > out.json
To get just the list of filenames with line numbers from the resulting out.json
file:
require 'json'
data = JSON.parse(File.read('out.json'))
examples = data['examples'].map do |example|
"#{example['file_path']}:#{example['line_number']}"
end
Now examples
will contain an array of file paths like:
["./spec/models/user_spec.rb:19", "spec/models/user_spec.rb:29"]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With