Last active
January 4, 2016 08:39
-
-
Save letmein/8597204 to your computer and use it in GitHub Desktop.
Debugging cross-test dependencies
This file contains hidden or 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
| rspec --require ./lib/rspec_debug_formatter.rb --format RSpecDebugFormatter --seed 8812 --fail-fast spec/ |
This file contains hidden or 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
| 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