Skip to content

Instantly share code, notes, and snippets.

@rzane
Created March 6, 2025 19:49
Show Gist options
  • Save rzane/e231eecf0df343e25b0066792997b111 to your computer and use it in GitHub Desktop.
Save rzane/e231eecf0df343e25b0066792997b111 to your computer and use it in GitHub Desktop.
Convert RSpec failed examples.txt to line numbers
require 'bundler/setup'
require 'rspec'
$LOAD_PATH.unshift(File.join(Dir.pwd, 'spec'))
ids = `grep '| failed' spec/examples.txt | sed 's/|.*//'`.lines(chomp: true).map(&:rstrip)
# Require each file
ids.each { |failure| require_relative failure.split('[')[0] }
# Print example locations
RSpec.world.all_examples.each do |example|
puts example.metadata[:location] if ids.include?(example.id)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment