Skip to content

Instantly share code, notes, and snippets.

@letmein
Last active January 4, 2016 08:39
Show Gist options
  • Save letmein/8597204 to your computer and use it in GitHub Desktop.
Save letmein/8597204 to your computer and use it in GitHub Desktop.
Debugging cross-test dependencies
rspec --require ./lib/rspec_debug_formatter.rb --format RSpecDebugFormatter --seed 8812 --fail-fast spec/
require 'rspec/core/formatters/base_text_formatter'
class RSpecDebugFormatter < RSpec::Core::Formatters::BaseFormatter
def example_group_started(example_group)
meta = example_group.metadata
if meta[:shared_group_name]
shared_group = meta[:example_group]
output << "#{shared_group[:file_path]}:#{shared_group[:line_number]}\n"
end
end
def example_started(example)
output << "#{example.location}\n" unless shared_example?(example.file_path, example.metadata[:example_group])
end
private
def shared_example?(file_path, meta)
file_path != meta[:file_path] || meta[:example_group] && shared_example?(file_path, meta[:example_group])
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment