-
Notifications
You must be signed in to change notification settings - Fork 576
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
Expose dom as an attribute on Test::Mojo #1045
Conversation
…ctly with Test::Mojo
I've wanted this on the off occasion where there are mixed api return types, like a JSON api for which one of the values is HTML. |
I'm less sure about changing how the |
@@ -17,7 +17,8 @@ use Mojo::Util qw(decode encode); | |||
use Test::More (); | |||
|
|||
has [qw(message success tx)]; | |||
has ua => sub { Mojo::UserAgent->new->ioloop(Mojo::IOLoop->singleton) }; | |||
has ua => sub { Mojo::UserAgent->new->ioloop(Mojo::IOLoop->singleton) }; | |||
has dom => sub { shift->tx->res->dom }; |
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.
Is an attribute really needed here? How much faster is it than a method?
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 don't think it is intended as a shortcut but rather as an assignable DOM.
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.
Yeah, the idea is that you can use Test::Mojo dom methods without doing a request by assigning a Mojo::DOM object, as illustrated by the changes in t/mojo/dom.t
👎 Really don't like the changes in |
Ok, I'm definitively not attached to the t/mojo/dom.t changes, will add a
few tests to t/test-mojo.t or so instead. Closing this pull request and
will reopen when I'm done.
M
…On Mon, Jan 30, 2017 at 10:04 PM Sebastian Riedel ***@***.***> wrote:
👎 Really don't like the changes in dom.t. If you want better test
coverage for Test::Mojo, then i believe the right way to do it would be a
new test file with tests for pass and fail. Not sure how to do it best, but
i'm sure other test modules have tests too.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1045 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAAVluzXdN-N6j1ziVGo0vTe8IOFGow0ks5rXlBOgaJpZM4Lx5Mw>
.
|
FYI, once Perl ships a major (minor, sigh) version with Test2 (perl 5.25.1 includes it, so perl 5.26 will), I intend to rewrite the Test::Mojo internals and test them better (with approval of course). |
Summary
Expose dom as an attribute on Test::Mojo to allow testing Mojo::DOM objects without involving a user agent. Also makes some tests in t/mojo/mojo-dom.t a bit simpler to read.
Motivation
This makes it easy to use Test::Mojo to test the contents of HTML/XML strings.