-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Indent all extra failure lines correctly in system tests #2321
Indent all extra failure lines correctly in system tests #2321
Conversation
👋 Can you add some tests and provide a sample output before/after? Cheers! |
@JonRowe here's some sample output: Before:
After:
I'm honestly not entirely sure why there are newlines being added before the As for tests, I initially started to write some tests for this, but ran into a bit of a roadblock when trying to figure out how best to write a test for something like this. This is about where I got stuck: describe '#after' do
it 'sets the :extra_failure_lines metadata to an array of STDOUT lines' do
group = RSpec::Core::ExampleGroup.describe do
include SystemExampleGroup
def original_after_teardown
puts 'foo'
puts 'bar'
end
end
example = group.new
group.hooks.run(:after, :example, example)
expect(example.metadata[:extra_failure_lines]).to eq(['foo', 'bar'])
end
end Do you have some guidance on that? |
Hello! Having looked at your output I'd say the first is correct, but Rails is wrapping across to a second line? e.g. I'd expect
I guess this could be considered more correct though:
|
I think it'd be great if either of those was the output! However, the maintenance/implementation burden doesn't quite seem worth the "benefit" of aligning the colons vertically, particularly since the output included in |
I feel rails is aligning the output given your first example? But somehow an extra newline is being generated? |
Rails is not doing any kind of output-massaging, it's simply doing Sorry for any confusion, I hope this additional contexts helps explain my proposed change here! |
Ah I follow now 😂, so we're looking for:
|
Yep, that's the ideal! I don't think rspec-rails should be doing too much to try and fix any weird additional newlines from Rails, but having each separate Assuming you're 👍 on that, do you have a recommendation on the ideal approach to test this? Thanks! |
Something along these lines will get you closer:
You need to run the example and trick it into using one of its hooks, maybe a custom driver that returns dummy screenshot urls? |
dcf9e2f
to
1f16bb4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay here, @JonRowe! Have had a busy couple of weeks, but finally managed to come back to this and add a test. Just 1 remaining question for you, then this should be good to go. Thanks for all of your help!
1f16bb4
to
067f4bc
Compare
If the output from Rails' system test teardown is multiple lines, we should try and render all of the lines with proper indentation. This can happen on `rails/rails@master` now that failure screenshots can include the page HTML (rails/rails@36545), and can actually happen with v6.0.2.2 if the `method_name` ends up being a little too long.
067f4bc
to
b7741f2
Compare
Thanks! |
Awesome, thanks again for all your help @JonRowe! |
…lure-lines-array Indent all extra failure lines correctly in system tests
This is my first contribution to rspec-rails, so if I've missed anything, or done anything wrong, please let me know!
If the output from Rails' system test teardown is multiple lines, we should try and render all of the lines with proper indentation.
This can happen on
rails/rails@master
now that failure screenshots can include the page HTML (rails/rails@36545), and can actually happen with v6.0.2.2 if themethod_name
ends up being a little too long.