-
-
Notifications
You must be signed in to change notification settings - Fork 753
Indent messages correctly in DocumentationFormatter. #2649
Conversation
Hello Samuel and thanks for this PR. Don't you think we should test this? Cheers |
Thanks Samuel! Yep I'd like to see a test for this and an indication of the change to the output as a sample! |
I am happy to add a test. However there is no current test for this. If we add a test, we are setting in stone how it should behave. Is that okay? Maybe we want to change this behaviour again in the future. |
Okay, I've added a spec. I don't want to make this any more complicated, however it does make me wonder if the message should come after the example name. While right now we are retaining the current behaviour which is probably good, maybe there is another discussion to be had regarding how to output the messages. |
Then we will change the test :) No problem for me.
Yes maybe. I think it's ok for a first version. |
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.
LGTM thanks Samuel
Are we good to merge? |
Sorry, missed adding it in |
I much more happy with the new expected output now. |
I agree, it's nicer, it's just a bigger change and affects the underlying assumptions about what message output does. I wasn't so confident to make a big change. |
I think the main criteria you should consider is, give that currently it is:
Is it already so hard to read that
couldn't really make it any worse than it already is, then merging this PR only makes the situation better, and no worse for any existing use case. |
My comment referred to the original implementation, not the one I've suggested as being mergeable. |
Okay, fair enough, well I've implemented what you asked but travis has exploded, strangely enough all tests passing locally, not sure what's going on. |
The cucumber is failing because message is used to report messages before the suite too, so oddly, I think there needs to be another flush before the examples run |
@JonRowe why is it not failing for me locally, do I need to install cucumber? |
cucumber is installed if you've done a bundle install, but you need to run it, its not part of our spec suite |
Is this what you are thinking? |
|
That should be one way |
I tried it but it still fails. |
How about this?
|
@JonRowe Okay it's implemented and ready for your review. |
@JonRowe any chance we can merge this? Everything you requested was implemented. |
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 to be so nitpicky @ioquatix, I think we should change this slightly. If we keep track of wether we are in an example (causing the buffering to happen) but print immediately or not I feel the behaviour is cleaner. It means that outside of an example (groups, setup etc) its immediately printed at the current indent level, but if an example is running its buffered and indented further.
@JonRowe are you happy with this now? |
@JonRowe Any update? |
Sorry for the delay. Actual code looks good to me. Thanks Samuel |
Sorry for the delay, lots on my plate atm |
@JonRowe I made a few minor changes to your suggestions.
Is there any chance Also, do we need |
:example_passed, :example_pending, :example_failed | ||
|
||
def initialize(output) | ||
super | ||
@group_level = 0 | ||
|
||
@example_started = false |
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.
Its not the name of the method, its the state of the example, I prefer running as it indicated the state now, not what it was.
end | ||
|
||
private | ||
|
||
def flush_messages | ||
if @messages.any? |
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.
You don't need to check for this, you can just iterate and clear, its a no op on an empty array.
Example started is called once at the start of an example, one of the three result methods should be called always so yes you need it in pending. |
Okay changes made. |
Will merge when green |
Awesome, look forward to seeing this in my specs :) |
Also thanks for all your feedback, and doubly so if you've been preoccupied with something else! |
Just a notice. Samuel did a video while working on this PR. https://youtu.be/tj4Bz_HaDIk 👌 |
Indent messages correctly in DocumentationFormatter.
Indent messages correctly in DocumentationFormatter. --- This commit was imported from rspec/rspec-core@e570a0c.
This commit was imported from rspec/rspec-core@25b10ef.
When using
example.reporter.message
, it would be nice if the messages were indented correctly, so that it's clear it relates to the current spec being executed.