Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/atoomic/test-mojo-role-debug-json

extension of Test::Mojo::Role::Debug
https://github.com/atoomic/test-mojo-role-debug-json

Last synced: about 2 months ago
JSON representation

extension of Test::Mojo::Role::Debug

Awesome Lists containing this project

README

        

[![Actions Status](https://github.com/atoomic/Test-Mojo-Role-Debug-JSON/workflows/linux/badge.svg)](https://github.com/atoomic/Test-Mojo-Role-Debug-JSON/actions)
[![Actions Status](https://github.com/atoomic/Test-Mojo-Role-Debug-JSON/workflows/macos/badge.svg)](https://github.com/atoomic/Test-Mojo-Role-Debug-JSON/actions)
[![Actions Status](https://github.com/atoomic/Test-Mojo-Role-Debug-JSON/workflows/windows/badge.svg)](https://github.com/atoomic/Test-Mojo-Role-Debug-JSON/actions)

# NAME

Test::Mojo::Role::Debug::JSON - a JSON extension to Test::Mojo::Role::Debug

# VERSION

version 0.006

# SYNOPSIS

# DESCRIPTION

When you chain up a bunch of tests and they fail, you really want an easy
way to dump up your markup at a specific point in that chain and see
what's what. This module comes to the rescue.

# NAME

Test::Mojo::Role::Debug::JSON - Test::Mojo role to make debugging test failures easier

This is an extension of [Test::Mojo::Role::Debug](https://metacpan.org/pod/Test%3A%3AMojo%3A%3ARole%3A%3ADebug).
Its usage and syntax are very similar.
Test::Mojo::Role::Debug provides the subs 'd' and 'da',
whereas Test::Mojo::Role::Debug::JSON provides the additional 'djson' and 'djsona'

```perl
use Test::More;

use Test::Mojo::WithRoles 'Debug::JSON';

my $t = Test::Mojo::WithRoles->new('MyApp');

$t->get_ok('/')->status_is(200)
->d # Does nothing, since test succeeded - on failure dump content
->djson # Does nothing, since test succeeded - on failure dump content as json
->json_like( { status => 'ok' } )
->da # Always dump reply content
->djsona # Always dump the reply content as json
;

done_testing;
```

# METHODS

You have all the methods provided by [Test::Mojo](https://metacpan.org/pod/Test%3A%3AMojo), [Test::Mojo::Role::Debug](https://metacpan.org/pod/Test%3A%3AMojo%3A%3ARole%3A%3ADebug), plus these:

## `djson`

```
$t->djson; # print the answer as json
$t->djson('/status'); # print specific node as json
```

**Returns** its invocant.
On failure of previous tests (see ["success" in Mojo::DOM](https://metacpan.org/pod/Mojo%3A%3ADOM#success)),
dumps the content output as json. Optionally, takes a JSON pointer to aid subset
larger responses.

## `djsona`

```
$t->djsona;
$t->djsona('/status');
```

Same as ["djson"](#djson), except it always dumps, regardless of whether the previous
test failed or not.

# SEE ALSO

[Test::Mojo::Role::Debug::JSON](https://metacpan.org/pod/Test%3A%3AMojo%3A%3ARole%3A%3ADebug%3A%3AJSON), [Test::Mojo](https://metacpan.org/pod/Test%3A%3AMojo) (["or" in Test::Mojo](https://metacpan.org/pod/Test%3A%3AMojo#or) in particular), [Mojo::DOM](https://metacpan.org/pod/Mojo%3A%3ADOM)

# REPOSITORY

Fork this module on GitHub:
[https://github.com/atoomic/Test-Mojo-Role-Debug-JSON](https://github.com/atoomic/Test-Mojo-Role-Debug-JSON)

# BUGS

To report bugs or request features, please use
[https://github.com/atoomic/Test-Mojo-Role-Debug-JSON/issues](https://github.com/atoomic/Test-Mojo-Role-Debug-JSON/issues)

Contrinuous integration coverage
[https://travis-ci.org/atoomic/Test-Mojo-Role-Debug-JSON](https://travis-ci.org/atoomic/Test-Mojo-Role-Debug-JSON)

# AUTHOR

# CONTRIBUTORS

# LICENSE

You can use and distribute this module under the same terms as Perl itself.
See the `LICENSE` file included in this distribution for complete
details.

# AUTHOR

Nicolas R

# COPYRIGHT AND LICENSE

This software is copyright (c) 2018 by Nicolas R.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.