-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Enable logging non-string - fix #1410 #1412
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
ec18a5f
Enable logging non-string - fix #1410
vincent-psarga 731c6f2
Remove unused error
vincent-psarga f609fba
Enable logging multiple objects in a single call (like puts)
vincent-psarga 0db705c
Also show kwargs usse with log in tests
vincent-psarga File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -191,11 +191,12 @@ def step_match(text) | |
run_step 'Loud' | ||
end | ||
|
||
it 'raises an exception if the message is not a String' do | ||
it 'calls `to_s` if the message is not a String' do | ||
expect(user_interface).to receive(:attach).with('["Not", 1, "string"]', 'text/x.cucumber.log+plain') | ||
dsl.Given(/Loud/) do | ||
log ['Not', 1, 'string'] | ||
end | ||
expect { run_step 'Loud' }.to raise_exception(Cucumber::LogTypeInvalid) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. indeed |
||
run_step 'Loud' | ||
end | ||
end | ||
|
||
|
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.
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.
Why the
dup
?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.
Otherwise we log the object itself and it will display its value at display time, not at log time (there a test showing that and it fails without the
dup
)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.
I understand why we used to do
message.dup
, but I don't think we needmessage.to_s.dup
. I thinkmessage.to_s
is sufficient.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.
(Me, a reader, thought this was because the string would be used in a mutable context.)
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.
I though the
to_s
would be enough too. In fact it's enough for non-string objects (obviously :D ) but when using a String we need thedup
.An example from the tests:
This test fails without the
dup
(we outputA\nA
instead ofa\nA
). I suspect that String.to_s do not return a duplicate but imply itself (also note, the test still usesputs
instead of log, but that'll be removed once we removed the override ofputs
bylog
)And @olleolleolle you're not wrong, it's just that the string might be mutated between the moment it I logged and the moment we actually display it.