Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respect extra_failure_lines in RSpec metadata #208

Merged
merged 1 commit into from
Jan 22, 2024

Conversation

mcmire
Copy link
Collaborator

@mcmire mcmire commented Jan 22, 2024

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 support extra_failure_lines, so anything in this metadata property is effectively discarded. This commit restores support.


Created from #195. Hat tip @willnet.

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 support
`extra_failure_lines`, so anything in this metadata property is
effectively discarded. This commit restores support.

Co-authored-by: willnet <netwillnet@gmail.com>
@mcmire mcmire force-pushed the respect-extra-failure-lines branch from 8d68486 to 6a964ed Compare January 22, 2024 05:12
@mcmire mcmire marked this pull request as ready for review January 22, 2024 05:21
@mcmire mcmire merged commit a343874 into main Jan 22, 2024
40 checks passed
@mcmire mcmire deleted the respect-extra-failure-lines branch January 30, 2024 03:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant