allow passing in context information to assert methods#9
Open
haarg wants to merge 1 commit intohouseabsolute:masterfrom
Open
allow passing in context information to assert methods#9haarg wants to merge 1 commit intohouseabsolute:masterfrom
haarg wants to merge 1 commit intohouseabsolute:masterfrom
Conversation
autarch
reviewed
Feb 19, 2017
Member
autarch
left a comment
There was a problem hiding this comment.
This looks pretty reasonable. I had a few comments about the details.
| init_arg => undef, | ||
| }, | ||
| context => { | ||
| isa => 'HashRef', |
Member
There was a problem hiding this comment.
I wonder if this really needs to be a HashRef. Is there any reason not to allow any defined value? I guess this would make including it in the as_string output harder, but as it stands this output won't be very helpful if the hashref contains any references of its own.
| if ($self->context and my %context = %{$self->context}) { | ||
| $str | ||
| .= ' (' | ||
| . join(', ', map { "$_: $context{$_}" } sort keys %context) |
Member
There was a problem hiding this comment.
We could just use Specio::PartialDump here, which would make even more sense if this wasn't required to be a hashref.
| }; | ||
|
|
||
| like( | ||
| $e->as_string, |
Member
There was a problem hiding this comment.
It'd be good to also test that $e->context contains what we expect.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This isn't meant to be a finished product, but a starting point for discussion.
What I'd like to be able to do is attach attribute information when doing assertions, and have that information end up in the exception object and stringification.