Respect extra_failure_lines in RSpec metadata #208
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
RSpec tests can have associated metadata, which is just a hash of content. One magic metadata property is
extra_failure_lines
. If this property is set, then RSpec will read its content and include it in the output it prints if the test fails.This property particularly comes into play in RSpec system specs, a wrapper around Rails system tests. If a system test fails, a screenshot is automatically taken of the page (provided the driver supports it) and a message is printed which details the path to the screenshot. RSpec's wrapper will capture output generated while the test is running and then store it in
extra_failure_lines
. By doing this, output (including the screenshot path, but potentially other information as well) is effectively moved to the spec failure message.This gem, as it patches key parts of
rspec-rails
, doesn't supportextra_failure_lines
, so anything in this metadata property is effectively discarded. This commit restores support.Created from #195. Hat tip @willnet.