summaryrefslogtreecommitdiffstats
path: root/t/stringify.t
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2012-10-11 14:22:55 -0500
committerJesse Luehrs <doy@tozt.net>2012-10-11 14:23:09 -0500
commitcd59caeec925cf0bf8625d567a442e3c46ae7475 (patch)
tree9fc7ba28aca00fec5f6c53ee1b18249fcd4df006 /t/stringify.t
parentc5ee7923bb6d38f138e58e7da5f9dfaa85bb9721 (diff)
downloadmoosex-validation-doctypes-cd59caeec925cf0bf8625d567a442e3c46ae7475.tar.gz
moosex-validation-doctypes-cd59caeec925cf0bf8625d567a442e3c46ae7475.zip
also provide stringification for the error object
Diffstat (limited to 't/stringify.t')
-rw-r--r--t/stringify.t33
1 files changed, 33 insertions, 0 deletions
diff --git a/t/stringify.t b/t/stringify.t
new file mode 100644
index 0000000..c8db5a4
--- /dev/null
+++ b/t/stringify.t
@@ -0,0 +1,33 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use Test::More;
+
+use Moose::Util::TypeConstraints 'find_type_constraint';
+
+use MooseX::Validation::Doctypes;
+
+doctype 'Person' => {
+ id => 'Str',
+ name => 'Str',
+ title => 'Str',
+};
+
+{
+ my $person = find_type_constraint('Person');
+ my $errors = $person->validate({ foo => "bar" });
+
+ is(
+ "$errors",
+ "invalid value undef for 'id'\n"
+ . "invalid value undef for 'name'\n"
+ . "invalid value undef for 'title'\n"
+ . "extra data found:\n"
+ . "{\n"
+ . " 'foo' => 'bar'\n"
+ . "}",
+ "stringified properly"
+ );
+}
+
+done_testing;