-
Notifications
You must be signed in to change notification settings - Fork 8
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
allow passing in context information to assert methods #9
base: master
Are you sure you want to change the base?
Conversation
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.
This looks pretty reasonable. I had a few comments about the details.
@@ -29,6 +29,9 @@ use Specio::OO; | |||
stack_trace => { | |||
init_arg => undef, | |||
}, | |||
context => { | |||
isa => 'HashRef', |
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 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) |
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.
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, |
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.
It'd be good to also test that $e->context
contains what we expect.
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.