Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from robrwo/rrwo/subclassing
Update MooX::JSON_LD to handle subclassing
- Loading branch information
Showing
4 changed files
with
77 additions
and
3 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
use strict; | ||
use warnings; | ||
|
||
use FindBin '$Bin'; | ||
use lib "$Bin/lib"; | ||
|
||
use Test::More; | ||
use MooTester3; | ||
|
||
ok(my $obj = MooTester3->new); | ||
isa_ok($obj, 'MooTester3' ); | ||
can_ok($obj, qw[ foo bar boop json_ld_type json_ld_fields | ||
json_ld_data json_ld json_ld_encoder ]); | ||
|
||
is($obj->foo, 'Foo', 'foo is Foo'); | ||
is($obj->bar, 'Bar', 'bar is Bar'); | ||
is($obj->boop, 'Bop!', 'boop is Bop!'); | ||
|
||
is_deeply($obj->json_ld_data, { | ||
'@type' => 'Another', | ||
'@context' => 'http://schema.org/', | ||
bax => 'Bar', | ||
baz => 'Bar Foo', | ||
boop => 'Bop!', | ||
zip => 'Pow', | ||
}, 'JSON data is correct'); | ||
|
||
is($obj->json_ld, '{ | ||
"@context" : "http://schema.org/", | ||
"@type" : "Another", | ||
"bax" : "Bar", | ||
"baz" : "Bar Foo", | ||
"boop" : "Bop!", | ||
"zip" : "Pow" | ||
} | ||
', 'JSON is correct'); | ||
|
||
done_testing; |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package MooTester3; | ||
|
||
use Moo; | ||
extends 'MooTester2'; | ||
|
||
use MooX::JSON_LD 'Another'; | ||
|
||
use namespace::autoclean; | ||
|
||
has zip => ( | ||
is => 'ro', | ||
default => 'Pow', | ||
json_ld => 1, | ||
); | ||
|
||
|
||
1; |