Test-WWW-Mechanize-Mojo-v0.0.17000755000764000764 013072365720 16473 5ustar00shlomifshlomif000000000000Test-WWW-Mechanize-Mojo-v0.0.17/Changes.old-Catalyst.txt000444000764000764 752613072365720 23312 0ustar00shlomifshlomif000000000000Revision history for Perl module Test::WWW::Mechanize::Catalyst: 0.51 Mon Mar 16 10:00 GMT 2009 - Doc updates from thejester - User agent fixes from ANDREMAR - Fix bug where redirect was followed on a 500 response - All remote requests (i.e. CATALYST_SERVER env var) now use our own mechanize object, rather than an unconfigurable one from Catalyst:Test 0.50 Tue Feb 17 09:12 GMT 2009 - Remove warning in HTTP::Cookies - Call BUILDALL 0.50_2 Thur Feb 12 09:47 GMT 2009 - Make t/multi_content_type.t handle case when server cant be started, which is almost always due to port in use. 0.50_1 Thur Feb 5 09:02 GMT 2009 - App classname no longer has to be passed to import: $m = T::W::M::C->new(catalyst_app => 'Catty') now works. - Can now use TWMC two test two different apps in the same perl interpreter due to the above change - Removed Test::WWW::Mechanize::Catalyst::Aux package as it isn't needed any more - Add 'host' accessor for white-label testing - Moosification - Can now test against remote CATALYST_SERVER without having to load the app class 0.45 Mon Nov 24 20:39:19 GMT 2008 - be forwards-compatible with Catalyst 5.80's virtual domain testing (thanks Jason Gottshall) 0.44 Mon Oct 27 13:48:22 GMT 2008 - fix longstanding bug with recent LWP, requiring WWW::Mechanize 1.50 (thanks to petdance, mst, dakkar) - add machine- and human-readable license, add abstract 0.43 Mon Aug 18 15:42:03 BST 2008 - add missing prereqs to Catalyst::Plugin::Session::State::Cookie and Catalyst::Plugin::Session::Store::Dummy (thanks kd) 0.42 Tue Apr 29 20:25:06 BST 2008 - stop multi_content_type.t killing smoke testing (patch by Andreas König) - fix a case where HTTP::Cookies dies when trying to extract_cookies (patch by Andreas Marienborg) - add Test::Exception as a prerequisite 0.41 Mon Sep 17 20:28:59 BST 2007 - fix to cope with gzipped content and the test from the rt.cpan queue about multiple content types (patch by Ash Berlin) 0.40 Tue Aug 21 20:51:13 BST 2007 - external requests (as per last release) are now only allowed if you set allow_external (sorry about that) 0.39 Sat Aug 4 08:01:38 BST 2007 - external requests are now allowed (patch by Edmund von der Burg) - remove Build.PL 0.38 Sat Jun 30 14:07:24 BST 2007 - document and test that you can use URLs without schema or hostname - add debug screen error to test diagnostics (patch by Jonathan Swartz) - add basic authentication support (patch by Gareth Kirwan) - add test for charset=utf-8 (patch by Chris Dolan) - added CATALYST_SERVER mention in the documentation (patch by Kieren Diment) 0.37 Tue Jun 6 08:54:07 BST 2006 - patch to follow LWP's $m->requests_redirectable() and small docpatch (thanks to Daniel McBrearty) - mention Catalyst::Test (thanks to guest) 0.36 Mon Apr 17 11:27:17 BST 2006 - perltidy - Catalyst debug screens are now failures (thanks to Kieren Diment) 0.35 Tue Jan 22 17:06:00 GMT 2006 - handle redirects (patch by Mark Fowler) 0.33 Tue Jun 7 17:38:45 BST 2005 - we need at least version 1.04 of Test::WWW::Mechanize (spotted by Jesse Vincent, patch by Shlomi Fish) 0.32 Tue May 3 16:14:40 BST 2005 - removed 'use Image::Size' in test, as spotted by SMPETERS 0.31 Sun Apr 17 10:30:18 BST 2005 - update for Catalyst 5.00 0.30 Fri Mar 25 04:34:50 GMT 2005 - add Test::WWW::Mechanize to prereqs - remove useless "use URI" - "borrow" lots of docs from Test::WWW::Mechanize - Catalyst 4.30 adds support for HTTP::Request objects in Catalyst::Test::request(), so use it (thanks to Christian Hansen) 0.29 Thu Mar 17 22:42:04 EST 2005 - initial release Test-WWW-Mechanize-Mojo-v0.0.17/Changes000444000764000764 563013072365720 20127 0ustar00shlomifshlomif000000000000Revision history for Perl module Test::WWW::Mechanize::Mojo : v0.0.17 2016-04-09 - Fix the tests in the upcomig perl-5.26.0 with the removal of "." from @INC . - For an example of a broken test, see: - http://www.cpantesters.org/cpan/report/c1f4ee94-16a3-11e7-8dda-ce31a02b686a - Thanks to DCOLLINS and other CPAN testers. v0.0.16 2014-02-02 - Fix the tests (and the code) on recent Mojoliciouses. - For an example of a broken test, see: - http://www.cpantesters.org/cpan/report/8fa17a8a-77ed-1014-a0c9-79c63567e6ce - Now requiring Mojolicious-4.75. v0.0.15 2014-02-01 - Add separate "LICENSE" file (CPANTS). - Specify minimum version of perl (CPANTS). - Rename "CHANGES" to "Changes" and moved the old Test::WWW::Mechanize::Catalyst changes to a different file. - Add t/cpan-changes.t . v0.0.14 2013-11-29 - Remove some old PODded-out code. - Caused a false positive at: - https://rt.cpan.org/Public/Bug/Display.html?id=91042 v0.0.13 2013-05-25 - Fix the tests for Mojolicious 4.07. v0.0.12 2013-05-21 - Add t/style-trailing-space.t and get rid of trailing space. v0.0.11 2012-08-01 - Got the POD coverage ( t/pod-coverage.t ) to pass again. v0.0.10 2012-05-13 - Update the module for recent versions of Mojolicious where $t->max_redirects() was removed (after being deprecated). - Thanks to tempire on #mojo on irc.perl.org for shedding some light on this issue. - This release coincides with the birthday of Sebastian Riedel ( https://metacpan.org/author/SRI ), the creator and maintainer of Mojolicious (and Catalyst previously). Happy birthday, Sebastian! v0.0.9 2011-05-19 - Got rid of warnings by switching from $t->client to $t->ua. - Thanks to Mirko Westermeier v0.0.8 2011-01-26 - Convert the mentioning of CATALYST_SERVER to MOJO_SERVER. - thanks to Insurgent Software. v0.0.7 2011-01-17 - Fixed mojjy.pl and the lib/Test/WWW/Mechanize/Mojo.pm code in recent Mojo versions. - app->start instead of shagadelic. - some tweaks to the ->$method->res. v0.0.6 2010-09-03 - Fixed mojjy.pl to avoid double encoding in recent Mojo versions. v0.0.5 2010-06-14 - Removed the call to Test::Mojo->redirect() which is no longer implemented in recent Mojos. v0.0.4 2010-03-17 - Now evaluating the GET parameters in requests by using URI.pm's ->path_query() instead of ->path(). v0.0.3 2010-03-04 - Fix submit_form_ok on the contemporary Mojo::Client . (with a test). v0.0.2 2010-03-02 - Add a missing empty line before an "=end". Without it, the POD was not displayed properly by perldoc and by http://search.cpan.org/ . - Add a t/pod-coverage.t test. v0.0.1 2010-03-02 - Ported to Mojo from Test::WWW::Mechanize::Catalyst - Convert from Module::Install to Module::Build . - All rights disclaimed. Test-WWW-Mechanize-Mojo-v0.0.17/LICENSE000444000764000764 5013113072365720 17655 0ustar00shlomifshlomif000000000000Terms of Perl itself a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or b) the "Artistic License" ---------------------------------------------------------------------------- GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS ---------------------------------------------------------------------------- The Artistic License Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications. Definitions: - "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through textual modification. - "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright Holder. - "Copyright Holder" is whoever is named in the copyright or copyrights for the package. - "You" is you, if you're thinking about copying or distributing this Package. - "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the computing community at large as a market that must bear the fee.) - "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers. 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. A Package modified in such a way shall still be considered the Standard Version. 3. You may otherwise modify your copy of this Package in any way, provided that you insert a prominent notice in each changed file stating how and when you changed that file, and provided that you do at least ONE of the following: a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or placing the modifications on a major archive site such as ftp.uu.net, or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. b) use the modified Package only within your corporation or organization. c) rename any non-standard executables so the names do not conflict with standard executables, which must also be provided, and provide a separate manual page for each non-standard executable that clearly documents how it differs from the Standard Version. d) make other distribution arrangements with the Copyright Holder. 4. You may distribute the programs of this Package in object code or executable form, provided that you do at least ONE of the following: a) distribute a Standard Version of the executables and library files, together with instructions (in the manual page or equivalent) on where to get the Standard Version. b) accompany the distribution with the machine-readable source of the Package with your modifications. c) accompany any non-standard executables with their corresponding Standard Version executables, giving the non-standard executables non-standard names, and clearly documenting the differences in manual pages (or equivalent), together with instructions on where to get the Standard Version. d) make other distribution arrangements with the Copyright Holder. 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically fall under the copyright of this Package, but belong to whomever generated them, and may be sold commercially, and may be aggregated with this Package. 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of this Package. 8. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End Test-WWW-Mechanize-Mojo-v0.0.17/MANIFEST000444000764000764 67113072365720 17745 0ustar00shlomifshlomif000000000000Build.PL Changes Changes.old-Catalyst.txt LICENSE MANIFEST This list of files META.json META.yml Makefile.PL README buildlib/Test/Run/Builder.pm lib/Test/WWW/Mechanize/Mojo.pm scripts/tag-release.pl t/auth-test.t t/cookies.t t/cpan-changes.t t/form_submit.t t/lib/Catty.pm t/lib/CattySession.pm t/lib/ExternalCatty.pm t/lib/MyMojjy.pm t/pod-coverage.t t/pod.t t/redirect.t t/simple.t t/style-trailing-space.t t/useragent.t t/white_label.t Test-WWW-Mechanize-Mojo-v0.0.17/Build.PL000444000764000764 243013072365720 20123 0ustar00shlomifshlomif000000000000use lib "./buildlib"; use Test::Run::Builder; use strict; use warnings; my $build = Test::Run::Builder->new( module_name => "Test::WWW::Mechanize::Mojo", configure_requires => { 'Module::Build' => '0.36', }, test_requires => { 'Test::Exception'=> '0', 'Test::More' => '0', 'Test::Mojo' => 0, }, requires => { 'base' => 0, 'Carp' => 0, 'Encode' => 0, 'HTML::Entities' => 0, 'LWP' => '5.816', 'Mojolicious::Lite' => 0, 'Mojolicious' => '4.75', 'perl' => '5.012', 'strict' => 0, 'Test::WWW::Mechanize' => '1.14', 'utf8' => 0, 'warnings' => 0, 'WWW::Mechanize' => '1.50', }, dist_version_from => "lib/Test/WWW/Mechanize/Mojo.pm", license => "perl", create_makefile_pl => 'traditional', meta_merge => { resources => { repository => "http://bitbucket.org/shlomif/perl-test-www-mechanize-mojo", homepage => "http://web-cpan.berlios.de/modules/Test-WWW-Mechanize-Mojo/", }, keywords => [ ], }, ); $build->create_build_script; Test-WWW-Mechanize-Mojo-v0.0.17/Makefile.PL000444000764000764 144613072365720 20607 0ustar00shlomifshlomif000000000000# Note: this file was auto-generated by Module::Build::Compat version 0.4218 require 5.012; use ExtUtils::MakeMaker; WriteMakefile ( 'NAME' => 'Test::WWW::Mechanize::Mojo', 'VERSION_FROM' => 'lib/Test/WWW/Mechanize/Mojo.pm', 'PREREQ_PM' => { 'Carp' => 0, 'Encode' => 0, 'HTML::Entities' => 0, 'LWP' => '5.816', 'Mojolicious' => '4.75', 'Mojolicious::Lite' => 0, 'Test::WWW::Mechanize' => '1.14', 'WWW::Mechanize' => '1.50', 'base' => 0, 'strict' => 0, 'utf8' => 0, 'warnings' => 0 }, 'INSTALLDIRS' => 'site', 'EXE_FILES' => [], 'PL_FILES' => {} ) ; Test-WWW-Mechanize-Mojo-v0.0.17/META.yml000444000764000764 176313072365720 20110 0ustar00shlomifshlomif000000000000--- abstract: 'Test::WWW::Mechanize for Mojo / Mojolicious' author: - unknown build_requires: Test::Exception: '0' Test::Mojo: '0' Test::More: '0' configure_requires: Module::Build: '0.36' dynamic_config: 1 generated_by: 'Module::Build version 0.4218, CPAN::Meta::Converter version 2.150001' keywords: [] license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: Test-WWW-Mechanize-Mojo provides: Test::WWW::Mechanize::Mojo: file: lib/Test/WWW/Mechanize/Mojo.pm version: v0.0.17 requires: Carp: '0' Encode: '0' HTML::Entities: '0' LWP: '5.816' Mojolicious: '4.75' Mojolicious::Lite: '0' Test::WWW::Mechanize: '1.14' WWW::Mechanize: '1.50' base: '0' perl: '5.012' strict: '0' utf8: '0' warnings: '0' resources: homepage: http://web-cpan.berlios.de/modules/Test-WWW-Mechanize-Mojo/ license: http://dev.perl.org/licenses/ repository: http://bitbucket.org/shlomif/perl-test-www-mechanize-mojo version: v0.0.17 Test-WWW-Mechanize-Mojo-v0.0.17/META.json000444000764000764 316613072365720 20257 0ustar00shlomifshlomif000000000000{ "abstract" : "Test::WWW::Mechanize for Mojo / Mojolicious", "author" : [ "unknown" ], "dynamic_config" : 1, "generated_by" : "Module::Build version 0.4218", "keywords" : [], "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "Test-WWW-Mechanize-Mojo", "prereqs" : { "configure" : { "requires" : { "Module::Build" : "0.36" } }, "runtime" : { "requires" : { "Carp" : "0", "Encode" : "0", "HTML::Entities" : "0", "LWP" : "5.816", "Mojolicious" : "4.75", "Mojolicious::Lite" : "0", "Test::WWW::Mechanize" : "1.14", "WWW::Mechanize" : "1.50", "base" : "0", "perl" : "5.012", "strict" : "0", "utf8" : "0", "warnings" : "0" } }, "test" : { "requires" : { "Test::Exception" : "0", "Test::Mojo" : "0", "Test::More" : "0" } } }, "provides" : { "Test::WWW::Mechanize::Mojo" : { "file" : "lib/Test/WWW/Mechanize/Mojo.pm", "version" : "v0.0.17" } }, "release_status" : "stable", "resources" : { "homepage" : "http://web-cpan.berlios.de/modules/Test-WWW-Mechanize-Mojo/", "license" : [ "http://dev.perl.org/licenses/" ], "repository" : { "url" : "http://bitbucket.org/shlomif/perl-test-www-mechanize-mojo" } }, "version" : "v0.0.17" } Test-WWW-Mechanize-Mojo-v0.0.17/README000444000764000764 207613072365720 17515 0ustar00shlomifshlomif000000000000Test::WWW::Mechanize::Mojo - Test::WWW::Mechanize for Mojo Test::WWW::Mechanize::Mojo is a module to test Mojo applications using Test::WWW::Mechanize and WWW::Mechanize. It is based on Test::WWW::Mechanize::Catalyst . INSTALLATION To install this module, run the following commands: perl Build.PL ./Build ./Build test ./Build install SUPPORT AND DOCUMENTATION After installing, you can find documentation for this module with the perldoc command. perldoc Test::WWW::Mechanize::Mojo You can also look for information at: Search CPAN http://search.cpan.org/dist/Test-WWW-Mechanize-Mojo/ CPAN Request Tracker: http://rt.cpan.org/NoAuth/Bugs.html?Dist=Test::WWW::Mechanize::Mojo AnnoCPAN, annotated CPAN documentation: http://annocpan.org/dist/Test::WWW::Mechanize::Mojo CPAN Ratings: http://cpanratings.perl.org/d/Test::WWW::Mechanize::Mojo COPYRIGHT AND LICENCE Copyright (C) 2005-8, Leon Brocard This module is free software; you can redistribute it or modify it under the same terms as Perl itself. Test-WWW-Mechanize-Mojo-v0.0.17/buildlib000755000764000764 013072365720 20261 5ustar00shlomifshlomif000000000000Test-WWW-Mechanize-Mojo-v0.0.17/buildlib/Test000755000764000764 013072365720 21200 5ustar00shlomifshlomif000000000000Test-WWW-Mechanize-Mojo-v0.0.17/buildlib/Test/Run000755000764000764 013072365720 21744 5ustar00shlomifshlomif000000000000Test-WWW-Mechanize-Mojo-v0.0.17/buildlib/Test/Run/Builder.pm000444000764000764 316713072365720 24034 0ustar00shlomifshlomif000000000000package Test::Run::Builder; use strict; use warnings; use Module::Build; use vars qw(@ISA); @ISA = (qw(Module::Build)); sub ACTION_runtest { my ($self) = @_; my $p = $self->{properties}; $self->depends_on('code'); local @INC = @INC; # Make sure we test the module in blib/ unshift @INC, (File::Spec->catdir($p->{base_dir}, $self->blib, 'lib'), File::Spec->catdir($p->{base_dir}, $self->blib, 'arch')); $self->do_test_run_tests; } sub ACTION_distruntest { my ($self) = @_; $self->depends_on('distdir'); my $start_dir = $self->cwd; my $dist_dir = $self->dist_dir; chdir $dist_dir or die "Cannot chdir to $dist_dir: $!"; # XXX could be different names for scripts $self->run_perl_script('Build.PL') # XXX Should this be run w/ --nouse-rcfile or die "Error executing 'Build.PL' in dist directory: $!"; $self->run_perl_script('Build') or die "Error executing 'Build' in dist directory: $!"; $self->run_perl_script('Build', [], ['runtest']) or die "Error executing 'Build test' in dist directory"; chdir $start_dir; } sub do_test_run_tests { my $self = shift; require Test::Run::CmdLine::Iface; my $test_run = Test::Run::CmdLine::Iface->new( { 'test_files' => [glob("t/*.t")], } # 'backend_params' => $self->_get_backend_params(), ); return $test_run->run(); } sub ACTION_tags { return system(qw( ctags -f tags --recurse --totals --exclude=blib/** --exclude=t/lib/** --exclude=.svn --exclude='*~' --languages=Perl --langmap=Perl:+.t )); } 1; Test-WWW-Mechanize-Mojo-v0.0.17/lib000755000764000764 013072365720 17241 5ustar00shlomifshlomif000000000000Test-WWW-Mechanize-Mojo-v0.0.17/lib/Test000755000764000764 013072365720 20160 5ustar00shlomifshlomif000000000000Test-WWW-Mechanize-Mojo-v0.0.17/lib/Test/WWW000755000764000764 013072365720 20644 5ustar00shlomifshlomif000000000000Test-WWW-Mechanize-Mojo-v0.0.17/lib/Test/WWW/Mechanize000755000764000764 013072365720 22547 5ustar00shlomifshlomif000000000000Test-WWW-Mechanize-Mojo-v0.0.17/lib/Test/WWW/Mechanize/Mojo.pm000444000764000764 4100213072365720 24163 0ustar00shlomifshlomif000000000000package Test::WWW::Mechanize::Mojo; use strict; use warnings; use 5.012; use Carp qw/croak/; use Encode qw(); use HTML::Entities; use base 'Test::WWW::Mechanize'; use Test::Mojo; our $VERSION = '0.0.17'; our $APP_CLASS; my $Test = Test::Builder->new(); sub mojo_app { my $self = shift; return $self->{mojo_app}; } sub has_mojo_app { my $self = shift; return exists($self->{mojo_app}); } sub allow_external { my $self = shift; if (@_) { $self->{allow_external} = shift; } return $self->{allow_external}; } sub host { my $self = shift; if (@_) { $self->{host} = shift; } return $self->{host}; } sub clear_host { my $self = shift; delete($self->{host}); return; } sub has_host { my $self = shift; return exists($self->{host}); } sub tester { my $self = shift; if (@_) { $self->{tester} = shift; } return $self->{tester}; } sub new { my $class = shift; my $args = ref $_[0] ? $_[0] : { @_ }; my $tester = delete($args->{tester}); my $self = $class->SUPER::new(%$args); if ($tester) { $self->tester($tester); } else { $self->tester(Test::Mojo->new()); } $self->{allow_external} = 0; return $self; } sub _make_request { my ( $self, $request ) = @_; my $response = $self->_do_mojo_request($request); $response->header( 'Content-Base', $response->request->uri ) unless $response->header('Content-Base'); $self->cookie_jar->extract_cookies($response) if $self->cookie_jar; # fail tests under the Catalyst debug screen if ( !$self->{catalyst_debug} && $response->code == 500 && $response->content =~ /on Catalyst \d+\.\d+/ ) { my ($error) = ( $response->content =~ /(.*?)<\/code>/s ); $error ||= "unknown error"; decode_entities($error); $Test->diag("Catalyst error screen: $error"); $response->content(''); $response->content_type(''); } # check if that was a redirect if ( $response->header('Location') && $response->is_redirect && $self->redirect_ok( $request, $response ) ) { # remember the old response my $old_response = $response; # *where* do they want us to redirect to? my $location = $old_response->header('Location'); # no-one *should* be returning non-absolute URLs, but if they # are then we'd better cope with it. Let's create a new URI, using # our request as the base. my $uri = URI->new_abs( $location, $request->uri )->as_string; # make a new response, and save the old response in it $response = $self->_make_request( HTTP::Request->new( GET => $uri ) ); my $end_of_chain = $response; while ( $end_of_chain->previous ) # keep going till the end { $end_of_chain = $end_of_chain->previous; } # of the chain... $end_of_chain->previous($old_response); # ...and add us to it } else { $response->{_raw_content} = $response->content; } return $response; } sub _do_mojo_request { my ($self, $request) = @_; my $uri = $request->uri; $uri->scheme('http') unless defined $uri->scheme; $uri->host('localhost') unless defined $uri->host; $request = $self->prepare_request($request); $self->cookie_jar->add_cookie_header($request) if $self->cookie_jar; # Woe betide anyone who unsets MOJO_SERVER return $self->_do_remote_request($request) if $ENV{MOJO_SERVER}; # If there's no Host header, set one. unless ($request->header('Host')) { my $host = $self->has_host ? $self->host : $uri->host; $request->header('Host', $host); } my $res = $self->_check_external_request($request); return $res if $res; my @creds = $self->get_basic_credentials( "Basic", $uri ); $request->authorization_basic( @creds ) if @creds; my $t = $self->tester; # Client my $client = $t->ua; $client->server->app($t->app); my $method = lc($request->method()); my %headers = ( map { $_ => $request->header($_) } $request->header_field_names() ); my $mojo_res = $client->$method($uri->path_query(), { %headers }, $request->content, )->res; my $response = HTTP::Response->new( $mojo_res->code(), $mojo_res->message(), [ %{$mojo_res->headers->to_hash()} ], $mojo_res->body() ); # LWP would normally do this, but we dont get down that far. $response->request($request); return $response; } sub _check_external_request { my ($self, $request) = @_; # If there's no host then definatley not an external request. $request->uri->can('host_port') or return; if ( $self->allow_external && $request->uri->host_port ne 'localhost:80' ) { return $self->SUPER::_make_request($request); } return undef; } sub _do_remote_request { my ($self, $request) = @_; my $res = $self->_check_external_request($request); return $res if $res; my $server = URI->new( $ENV{MOJO_SERVER} ); if ( $server->path =~ m|^(.+)?/$| ) { my $path = $1; $server->path("$path") if $path; # need to be quoted } # the request path needs to be sanitised if $server is using a # non-root path due to potential overlap between request path and # response path. if ($server->path) { # If request path is '/', we have to add a trailing slash to the # final request URI my $add_trailing = $request->uri->path eq '/'; my @sp = split '/', $server->path; my @rp = split '/', $request->uri->path; shift @sp;shift @rp; # leading / if (@rp) { foreach my $sp (@sp) { $sp eq $rp[0] ? shift @rp : last } } $request->uri->path(join '/', @rp); if ( $add_trailing ) { $request->uri->path( $request->uri->path . '/' ); } } $request->uri->scheme( $server->scheme ); $request->uri->host( $server->host ); $request->uri->port( $server->port ); $request->uri->path( $server->path . $request->uri->path ); return $self->SUPER::_make_request($request); } 1; __END__ =head1 NAME Test::WWW::Mechanize::Mojo - Test::WWW::Mechanize for Mojo / Mojolicious =head1 SYNOPSIS # We're in a t/*.t test script... use Test::WWW::Mechanize::Mojo; my $tester = Test::Mojo->new(); # To test a Mojo application my $mech = Test::WWW::Mechanize::Mojo->new(tester => $tester); $mech->get_ok("/"); # no hostname needed is($mech->ct, "text/html"); $mech->title_is("Root", "On the root page"); $mech->content_contains("This is the root page", "Correct content"); $mech->follow_link_ok({text => 'Hello'}, "Click on Hello"); # ... and all other Test::WWW::Mechanize methods # White label site testing $mech->host("foo.com"); $mech->get_ok("/"); =head1 DESCRIPTION L is an MVC Web Application Framework. L is a subclass of L that incorporates features for web application testing. The L module meshes the two to allow easy testing of L applications without needing to starting up a web server. Testing web applications has always been a bit tricky, normally requiring starting a web server for your application and making real HTTP requests to it. This module allows you to test L web applications but does not require a server or issue HTTP requests. Instead, it passes the HTTP request object directly to L. Thus you do not need to use a real hostname: "http://localhost/" will do. However, this is optional. The following two lines of code do exactly the same thing: $mech->get_ok('/action'); $mech->get_ok('http://localhost/action'); Links which do not begin with / or are not for localhost can be handled as normal Web requests - this is handy if you have an external single sign-on system. You must set allow_external to true for this: $mech->allow_external(1); You can also test a remote server by setting the environment variable MOJO_SERVER; for example: $ MOJO_SERVER=http://example.com/myapp prove -l t will run the same tests on the application running at http://example.com/myapp regardless of whether or not you specify http:://localhost for Test::WWW::Mechanize::Mojo. Furthermore, if you set MOJO_SERVER, the server will be regarded as a remote server even if your links point to localhost. Thus, you can use Test::WWW::Mechanize::Mojo to test your live webserver running on your local machine, if you need to test aspects of your deployment environment (for example, configuration options in an http.conf file) instead of just the Mojo request handling. This makes testing fast and easy. L provides functions for common web testing scenarios. For example: $mech->get_ok( $page ); $mech->title_is( "Invoice Status", "Make sure we're on the invoice page" ); $mech->content_contains( "Andy Lester", "My name somewhere" ); $mech->content_like( qr/(cpan|perl)\.org/, "Link to perl.org or CPAN" ); This module supports cookies automatically. To use this module you must pass it the name of the application. See the SYNOPSIS above. Note that Mojo has a special developing feature: the debug screen. By default this module will treat responses which are the debug screen as failures. If you actually want to test debug screens, please use: $mmech->{catalyst_debug} = 1; An alternative to this module is L. =head1 CONSTRUCTOR =head2 new Behaves like, and calls, L's C method. Any params passed in get passed to WWW::Mechanize's constructor. Note that we need to pass the name of the Catalyst application to the "use": use Test::WWW::Mechanize::Catalyst; use Test::Mojo; my $tester = Test::Mojo->new(); my $mech = Test::WWW::Mechanize::Catalyst->new(tester => $tester); In addition, one can specify a C<'tester'> argument as the Test::Mojo instance. =head1 METHODS =head2 allow_external Links which do not begin with / or are not for localhost can be handled as normal Web requests - this is handy if you have an external single sign-on system. You must set allow_external to true for this: $m->allow_external(1); =head2 mojo_app The name of the Mojo app which we are testing against. Read-only. =head2 has_mojo_app For internal use. =head2 tester For internal use. =head2 host The host value to set the "Host:" HTTP header to, if none is present already in the request. If not set (default) then Catalyst::Test will set this to localhost:80 =head2 clear_host Unset the host attribute. =head2 has_host Do we have a value set for the host attribute =head2 $mech->get_ok($url, [ \%LWP_options ,] $desc) A wrapper around WWW::Mechanize's get(), with similar options, except the second argument needs to be a hash reference, not a hash. Returns true or false. =head2 $mech->title_is( $str [, $desc ] ) Tells if the title of the page is the given string. $mech->title_is( "Invoice Summary" ); =head2 $mech->title_like( $regex [, $desc ] ) Tells if the title of the page matches the given regex. $mech->title_like( qr/Invoices for (.+)/ =head2 $mech->title_unlike( $regex [, $desc ] ) Tells if the title of the page does NOT match the given regex. $mech->title_unlike( qr/Invoices for (.+)/ =head2 $mech->content_is( $str [, $desc ] ) Tells if the content of the page matches the given string =head2 $mech->content_contains( $str [, $desc ] ) Tells if the content of the page contains I<$str>. =head2 $mech->content_lacks( $str [, $desc ] ) Tells if the content of the page lacks I<$str>. =head2 $mech->content_like( $regex [, $desc ] ) Tells if the content of the page matches I<$regex>. =head2 $mech->content_unlike( $regex [, $desc ] ) Tells if the content of the page does NOT match I<$regex>. =head2 $mech->page_links_ok( [ $desc ] ) Follow all links on the current page and test for HTTP status 200 $mech->page_links_ok('Check all links'); =head2 $mech->page_links_content_like( $regex,[ $desc ] ) Follow all links on the current page and test their contents for I<$regex>. $mech->page_links_content_like( qr/foo/, 'Check all links contain "foo"' ); =head2 $mech->page_links_content_unlike( $regex,[ $desc ] ) Follow all links on the current page and test their contents do not contain the specified regex. $mech->page_links_content_unlike(qr/Restricted/, 'Check all links do not contain Restricted'); =head2 $mech->links_ok( $links [, $desc ] ) Check the current page for specified links and test for HTTP status 200. The links may be specified as a reference to an array containing L objects, an array of URLs, or a scalar URL name. my @links = $mech->find_all_links( url_regex => qr/cnn\.com$/ ); $mech->links_ok( \@links, 'Check all links for cnn.com' ); my @links = qw( index.html search.html about.html ); $mech->links_ok( \@links, 'Check main links' ); $mech->links_ok( 'index.html', 'Check link to index' ); =head2 $mech->link_status_is( $links, $status [, $desc ] ) Check the current page for specified links and test for HTTP status passed. The links may be specified as a reference to an array containing L objects, an array of URLs, or a scalar URL name. my @links = $mech->links(); $mech->link_status_is( \@links, 403, 'Check all links are restricted' ); =head2 $mech->link_status_isnt( $links, $status [, $desc ] ) Check the current page for specified links and test for HTTP status passed. The links may be specified as a reference to an array containing L objects, an array of URLs, or a scalar URL name. my @links = $mech->links(); $mech->link_status_isnt( \@links, 404, 'Check all links are not 404' ); =head2 $mech->link_content_like( $links, $regex [, $desc ] ) Check the current page for specified links and test the content of each against I<$regex>. The links may be specified as a reference to an array containing L objects, an array of URLs, or a scalar URL name. my @links = $mech->links(); $mech->link_content_like( \@links, qr/Restricted/, 'Check all links are restricted' ); =head2 $mech->link_content_unlike( $links, $regex [, $desc ] ) Check the current page for specified links and test the content of each does not match I<$regex>. The links may be specified as a reference to an array containing L objects, an array of URLs, or a scalar URL name. my @links = $mech->links(); $mech->link_content_like( \@links, qr/Restricted/, 'Check all links are restricted' ); =head2 follow_link_ok( \%parms [, $comment] ) Makes a C call and executes tests on the results. The link must be found, and then followed successfully. Otherwise, this test fails. I<%parms> is a hashref containing the params to pass to C. Note that the params to C are a hash whereas the parms to this function are a hashref. You have to call this function like: $agent->follow_like_ok( {n=>3}, "looking for 3rd link" ); As with other test functions, C<$comment> is optional. If it is supplied then it will display when running the test harness in verbose mode. Returns true value if the specified link was found and followed successfully. The HTTP::Response object returned by follow_link() is not available. =head1 CAVEATS =head2 External Redirects and allow_external If you use non-fully qualified urls in your test scripts (i.e. anything without a host, such as C<< ->get_ok( "/foo") >> ) and your app redirects to an external URL, expect to be bitten once you come back to your application's urls (it will try to request them on the remote server.) This is due to a limitation in WWW::Mechanize. One workaround for this is that if you are expecting to redirect to an external site, clone the TWMC obeject and use the cloned object for the external redirect. =head1 SEE ALSO Related modules which may be of interest: L, L, L, L. =head1 AUTHOR =head2 Of Test::WWW::Mechanize::Catalyst Ash Berlin C<< >> Original Author: Leon Brocard, C<< >> =head2 Of Test::WWW::Mechanize::Mojo Shlomi Fish, L - while disclaiming all rights. =head1 COPYRIGHT Copyright (C) 2005-8, Leon Brocard =head1 LICENSE This module is free software; you can redistribute it or modify it under the same terms as Perl itself. =cut Test-WWW-Mechanize-Mojo-v0.0.17/t000755000764000764 013072365720 16736 5ustar00shlomifshlomif000000000000Test-WWW-Mechanize-Mojo-v0.0.17/t/redirect.t000444000764000764 255013072365720 21063 0ustar00shlomifshlomif000000000000#!perl use strict; use warnings; use Test::More tests => 28; use Test::Mojo; use Test::WWW::Mechanize::Mojo; use lib './t/lib'; require MyMojjy; my $root = "http://localhost"; my $t = Test::Mojo->new(); my $m; # TEST:$n=3; foreach my $where (qw{hi greetings bonjour}) { $m = Test::WWW::Mechanize::Mojo->new(tester => $t); # TEST*$n $m->get_ok( "$root/$where", "got something when we $where" ); # TEST*$n is( $m->base, "http://localhost/hello", "check got to hello 1/4" ); # TEST*$n is( $m->ct, "text/html", "check got to hello 2/4" ); # TEST*$n $m->title_is( "Hello",, "check got to hello 3/4" ); # TEST*$n $m->content_contains( "Hi there",, "check got to hello 4/4" ); # check that the previous response is still there my $prev = $m->response->previous; # TEST*$n ok( $prev, "have a previous" ); # TEST*$n is( $prev->code, 302, "was a redirect" ); # TEST*$n like( $prev->header('Location'), '/hello$/', "to the right place" ); } # extra checks for bonjour (which is a double redirect) my $prev = $m->response->previous->previous; # TEST ok( $prev, "have a previous previous" ); # TEST is( $prev->code, 302, "was a redirect" ); # TEST like( $prev->header('Location'), '/hi$/', "to the right place" ); $m->get("$root/redirect_with_500"); # TEST is ($m->status, 500, "Redirect not followed on 500"); Test-WWW-Mechanize-Mojo-v0.0.17/t/form_submit.t000444000764000764 146313072365720 21612 0ustar00shlomifshlomif000000000000#!perl use strict; use warnings; use Test::More tests => 5; use Test::Mojo; use Test::WWW::Mechanize::Mojo; use lib './t/lib'; require MyMojjy; use Encode qw(); use Test::WWW::Mechanize::Mojo; my $root = "http://localhost"; my $t = Test::Mojo->new(); my $m = Test::WWW::Mechanize::Mojo->new( autocheck => 0, tester => $t,); # TEST $m->get_ok("$root/form"); # TEST is( $m->ct, "text/html" ); # TEST $m->title_is("Form test"); my $email = "sophie\@hello.tld"; # $t->post_ok("/form-submit", # { 'Content-Type' => 'application/x-www-form-urlencoded'} , # 'email=shlomif' # ); $m->submit_form_ok( { form_id => "register", fields => { email => $email, }, }, "Was able to submit form.", ); # TEST $m->content_like( qr{Your email is \Q$email\E} ); Test-WWW-Mechanize-Mojo-v0.0.17/t/style-trailing-space.t000444000764000764 73013072365720 23300 0ustar00shlomifshlomif000000000000#!/usr/bin/perl use strict; use warnings; use Test::More; eval "use Test::TrailingSpace"; if ($@) { plan skip_all => "Test::TrailingSpace required for trailing space test."; } else { plan tests => 1; } my $finder = Test::TrailingSpace->new( { root => '.', filename_regex => qr/(?:(?:\.(?:t|pm|pl|PL|yml|json|arc|vim))|README|Changes|LICENSE|MANIFEST)\z/, }, ); # TEST $finder->no_trailing_space( "No trailing space was found." ); Test-WWW-Mechanize-Mojo-v0.0.17/t/simple.t000444000764000764 365313072365720 20560 0ustar00shlomifshlomif000000000000#!perl use strict; use warnings; use Test::More tests => 25; use Test::Mojo; use Test::WWW::Mechanize::Mojo; use lib './t/lib'; require MyMojjy; use Encode qw(); use Test::WWW::Mechanize::Mojo; my $root = "http://localhost"; my $t = Test::Mojo->new(); my $m = Test::WWW::Mechanize::Mojo->new( autocheck => 0, tester => $t,); # TEST $m->get_ok("$root/"); # TEST is( $m->ct, "text/html" ); # TEST $m->title_is("Root"); # TEST $m->content_contains("This is the root page"); # TEST $m->follow_link_ok( { text => 'Hello' } ); # TEST is( $m->base, "http://localhost/hello/" ); # TEST is( $m->ct, "text/html" ); # TEST $m->title_is("Hello"); my $bytes = "Hi there! ☺"; my $chars = Encode::decode( 'utf-8', $bytes ); # TEST $m->content_contains( $chars, qq{content contains "$bytes"}); #use Devel::Peek; Dump $m->content; #Dump(Encode::decode('utf-8', "Hi there! ☺")); #exit; # TEST $m->get_ok("/"); # TEST is( $m->ct, "text/html" ); # TEST $m->title_is("Root"); # TEST $m->content_contains("This is the root page"); # TEST $m->get_ok("http://example.com/"); # TEST is( $m->ct, "text/html" ); # TEST $m->title_is("Root"); # TEST $m->content_contains("This is the root page"); # TEST $m->get_ok("/hello/"); # TEST is( $m->ct, "text/html" ); # TEST $m->title_is("Hello"); # TEST $m->content_contains( $chars, qq{content contains "$bytes"}); # TEST $m->get_ok('/with-params?one=foo&two=bar'); # TEST $m->content_contains("[foo]{bar}", "Get params are OK."); # TEST $m->get_ok('/with-params?one=sophie&two=jack'); # TEST $m->content_contains("[sophie]{jack}", "Get params (#2) are OK."); =begin remmed_out SKIP: { eval { require Compress::Zlib; }; skip "Compress::Zlib needed to test gzip encoding", 4 if $@; #===TEST $m->get_ok("$root/gzipped/"); #===TEST is( $m->ct, "text/html" ); #===TEST $m->title_is("Hello"); #==TEST $m->content_contains( $chars, qq{content contains "$bytes"}); } =end remmed_out =cut Test-WWW-Mechanize-Mojo-v0.0.17/t/pod-coverage.t000444000764000764 25413072365720 21614 0ustar00shlomifshlomif000000000000#!perl -T use Test::More; eval "use Test::Pod::Coverage 1.04"; plan skip_all => "Test::Pod::Coverage 1.04 required for testing POD coverage" if $@; all_pod_coverage_ok(); Test-WWW-Mechanize-Mojo-v0.0.17/t/cpan-changes.t000444000764000764 26213072365720 21567 0ustar00shlomifshlomif000000000000#!/usr/bin/perl use strict; use warnings; use Test::More; eval 'use Test::CPAN::Changes'; plan skip_all => 'Test::CPAN::Changes required for this test' if $@; changes_ok(); Test-WWW-Mechanize-Mojo-v0.0.17/t/auth-test.t000444000764000764 101213072365720 21170 0ustar00shlomifshlomif000000000000#!perl use strict; use warnings; use Test::More tests => 5; use Test::Mojo; use Test::WWW::Mechanize::Mojo; use lib './t/lib'; require MyMojjy; my $t = Test::Mojo->new(); my $root = "http://localhost"; my $m = Test::WWW::Mechanize::Mojo->new(tester => $t); $m->credentials( 'user', 'pass' ); $m->get_ok("$root/check_auth_basic/"); is( $m->ct, "text/html" ); is( $m->status, 200 ); $m->credentials( 'boofar', 'pass' ); $m->get("$root/check_auth_basic/"); is( $m->ct, "text/html" ); is( $m->status, 401 ); Test-WWW-Mechanize-Mojo-v0.0.17/t/pod.t000444000764000764 22013072365720 20014 0ustar00shlomifshlomif000000000000#!perl -T use Test::More; eval "use Test::Pod 1.14"; plan skip_all => "Test::Pod 1.14 required for testing POD: $@" if $@; all_pod_files_ok(); Test-WWW-Mechanize-Mojo-v0.0.17/t/useragent.t000444000764000764 67313072365720 21243 0ustar00shlomifshlomif000000000000#!perl use strict; use warnings; use Test::More tests => 2; use Test::Mojo; use Test::WWW::Mechanize::Mojo; use lib './t/lib'; require MyMojjy; use Encode qw(); use Test::WWW::Mechanize::Mojo; my $root = "http://localhost"; my $agent = 'TestAgent/1.0'; my $t = Test::Mojo->new(); my $m = Test::WWW::Mechanize::Mojo->new(agent => $agent, tester => $t,); $m->get_ok("$root/user_agent"); $m->title_is($agent, "title is correct: $agent"); Test-WWW-Mechanize-Mojo-v0.0.17/t/white_label.t000444000764000764 101413072365720 21533 0ustar00shlomifshlomif000000000000#!perl use strict; use warnings; use Test::More tests => 4; use Test::Mojo; use Test::WWW::Mechanize::Mojo; use lib './t/lib'; require MyMojjy; use Encode qw(); use Test::WWW::Mechanize::Mojo; my $root = "http://localhost"; my $t = Test::Mojo->new(); my $m = Test::WWW::Mechanize::Mojo->new( tester => $t,); $m->host('foo.com'); # TEST $m->get_ok('/host'); # TEST $m->content_contains('Host: foo.com'); $m->clear_host; # TEST $m->get_ok('/host'); # TEST $m->content_contains('Host: localhost') or diag $m->content; Test-WWW-Mechanize-Mojo-v0.0.17/t/cookies.t000444000764000764 62213072365720 20674 0ustar00shlomifshlomif000000000000#!perl use strict; use warnings; use Test::More; use Test::More tests => 3; use Test::Mojo; use Test::WWW::Mechanize::Mojo; use lib './t/lib'; require MyMojjy; my $t = Test::Mojo->new(); my $root = "http://localhost"; my $m = Test::WWW::Mechanize::Mojo->new(tester => $t); $m->credentials( 'user', 'pass' ); # TEST $m->get_ok("/"); # TEST $m->title_is("Root"); # TEST is( $m->status, 200 ); Test-WWW-Mechanize-Mojo-v0.0.17/t/lib000755000764000764 013072365720 17504 5ustar00shlomifshlomif000000000000Test-WWW-Mechanize-Mojo-v0.0.17/t/lib/ExternalCatty.pm000444000764000764 224013072365720 22764 0ustar00shlomifshlomif000000000000package ExternalCatty; use strict; use warnings; use Catalyst qw/-Engine=HTTP/; our $VERSION = '0.01'; __PACKAGE__->config( name => 'ExternalCatty' ); __PACKAGE__->setup; sub default : Private { my ( $self, $c ) = @_; $c->response->content_type('text/html; charset=utf-8'); $c->response->output( html( 'Root', 'Hello, test ☺!' ) ); } # redirect to a redirect sub hello: Global { my ( $self, $context ) = @_; my $where = $context->uri_for('/'); $context->response->redirect($where); return; } sub html { my ( $title, $body ) = @_; return qq[ $title $body ]; } # The Cat HTTP server background option is useless here :-( # Thus we have to provide our own background method. sub background { my $self = shift; my $port = shift; my $child = fork; die "Can't fork Cat HTTP server: $!" unless defined $child; return $child if $child; if ( $^O !~ /MSWin32/ ) { require POSIX; POSIX::setsid() or die "Can't start a new session: $!"; } $self->run($port); } 1; Test-WWW-Mechanize-Mojo-v0.0.17/t/lib/Catty.pm000444000764000764 674413072365720 21276 0ustar00shlomifshlomif000000000000package Catty; use strict; use warnings; #use Catalyst; use Catalyst; use Cwd; use MIME::Base64; use Encode qw//; our $VERSION = '0.01'; Catty->config( name => 'Catty', root => cwd . '/t/root', ); Catty->setup(); Catty->log->levels("fatal"); sub default : Private { my ( $self, $context ) = @_; my $html = html( "Root", "This is the root page" ); $context->response->content_type("text/html"); $context->response->output($html); } sub hello : Global { my ( $self, $context ) = @_; my $str = Encode::encode('utf-8', "\x{263A}"); # ☺ my $html = html( "Hello", "Hi there! $str" ); $context->response->content_type("text/html; charset=utf-8"); $context->response->output($html); } # absolute redirect sub hi : Global { my ( $self, $context ) = @_; my $where = $context->uri_for('hello'); $context->response->redirect($where); return; } # partial (relative) redirect sub greetings : Global { my ( $self, $context ) = @_; $context->response->redirect("hello"); return; } # redirect to a redirect sub bonjour : Global { my ( $self, $context ) = @_; my $where = $context->uri_for('hi'); $context->response->redirect($where); return; } sub check_auth_basic : Global { my ( $self, $context ) = @_; my $auth = $context->req->headers->authorization; ($auth) = $auth =~ /Basic\s(.*)/i; $auth = decode_base64($auth); if ( $auth eq "user:pass" ) { my $html = html( "Auth", "This is the auth page" ); $context->response->content_type("text/html"); $context->response->output($html); return $context; } else { my $html = html( "Auth", "Auth Failed!" ); $context->response->content_type("text/html"); $context->response->output($html); $context->response->status("401"); return $context; } } sub redirect_with_500 : Global { my ( $self, $c ) = @_; $DB::single = 1; $c->res->redirect( $c->uri_for("/bonjour")); die "erk!"; } sub die : Global { my ( $self, $context ) = @_; my $html = html( "Die", "This is the die page" ); $context->response->content_type("text/html"); $context->response->output($html); die "erk!"; } sub name : Global { my ($self, $c) = @_; my $html = html( $c->config->{name}, "This is the die page" ); $c->response->content_type("text/html"); $c->response->output($html); } sub host : Global { my ($self, $c) = @_; my $host = $c->req->header('Host') || ""; my $html = html( $c->config->{name}, "Host: $host" ); $c->response->content_type("text/html"); $c->response->output($html); } sub html { my ( $title, $body ) = @_; return qq{ $title $body Hello. }; } sub gzipped : Global { my ( $self, $c ) = @_; # If done properly this test should check the accept-encoding header, but we # control both ends, so just always gzip the response. require Compress::Zlib; my $html = html( "Hello", "Hi there! ☺" ); $c->response->content_type("text/html; charset=utf-8"); $c->response->output( Compress::Zlib::memGzip($html) ); $c->response->content_encoding('gzip'); $c->response->headers->push_header( 'Vary', 'Accept-Encoding' ); } sub user_agent : Global { my ( $self, $c ) = @_; my $html = html($c->req->user_agent, $c->req->user_agent); $c->response->content_type("text/html; charset=utf-8"); $c->response->output( $html ); } 1; Test-WWW-Mechanize-Mojo-v0.0.17/t/lib/MyMojjy.pm000555000764000764 751013072365720 21603 0ustar00shlomifshlomif000000000000#!/usr/bin/env perl use Mojolicious::Lite; use MIME::Base64; use Encode qw//; use Cwd; use utf8; sub html { my ( $title, $body ) = @_; return qq{ $title $body Hello. }; } get '/check_auth_basic/' => sub { my $self = shift; my $auth = $self->req->headers->header("Authorization"); ($auth) = $auth =~ /Basic\s(.*)/i; $auth = decode_base64($auth); if ( $auth eq "user:pass" ) { my $html = html( "Auth", "This is the auth page" ); $self->render(text => $html); return; } else { my $html = html( "Auth", "Auth Failed!" ); $self->render(text => $html, status => "401",); return; } }; get "/hi" => sub { my $self = shift; $self->redirect_to('/hello'); return; }; get "/greetings" => sub { my $self = shift; # This relative URL is something that Catalyst eats and appears # in Catty.pm , but Mojo won't accept. # -- Shlomi Fish # $self->redirect_to('hello'); $self->redirect_to('/hello'); return; }; get "/bonjour" => sub { my $self = shift; $self->redirect_to('/hi'); return; }; get '/hello' => sub { my $self = shift; my $html = html( "Hello", "Hi there! ☺" ); # ☺ $self->res->headers->content_type("text/html; charset=utf-8"); $self->render(text => $html); return; }; get '/redirect_with_500' => sub { my $self = shift; $self->redirect_to('/bonjour'); die "erk!"; }; get "/die/" => sub { my $self = shift; my $html = html( "Die", "This is the die page" ); $self->render(text => $html); die "erk!"; }; sub _gzipped { my $self = shift; # If done properly this test should check the accept-encoding header, but we # control both ends, so just always gzip the response. require Compress::Zlib; my $html = html( "Hello", "Hi there! ☺" ); $self->res->headers->content_type("text/html; charset=utf-8"); $self->render(text => Compress::Zlib::memGzip($html) ); $self->res->headers->content_transfer_encoding('gzip'); $self->res->headers->add( 'Vary', 'Accept-Encoding' ); return; } get "/gzipped/" => \&_gzipped; get "/user_agent" => sub { my $self = shift; my $agent = $self->req->headers->user_agent(); my $html = html($agent, $agent); $self->render(text => $html); $self->res->headers->content_type("text/html; charset=utf-8"); return; }; get "/host" => sub { my $self = shift; my $host = $self->req->headers->header('Host') || ""; my $html = html( "Foo", "Host: $host" ); $self->render(text => $html); return; }; post "/form-submit" => sub { my $self = shift; my $html = html( "Foo", "Your email is " . $self->param("email")); $self->render(text => $html); return; }; get "/form" => sub { my $self = shift; $self->render(text => <<'EOF'); Form test
Email:
EOF return; }; get '/with-params' => sub { my $self = shift; $self->render(text => sprintf("[%s]{%s}", $self->param('one'), $self->param('two'))); }; get '/:groovy' => sub { my $self = shift; $self->render(text => $self->param('groovy'), layout => 'funky'); }; get '/' => sub { my $self = shift; $self->render(text => html("Root", "This is the root page")); return; }; app->start; =head1 TODO * Add a status (Not logged-in / Logged in as something) ruler to the top. =cut __DATA__ @@ layouts/funky.html.ep Foo Bar <%== content %> Test-WWW-Mechanize-Mojo-v0.0.17/t/lib/CattySession.pm000444000764000764 172313072365720 22632 0ustar00shlomifshlomif000000000000package CattySession; use strict; #use Catalyst; use Catalyst qw/ Session Session::State::Cookie Session::Store::Dummy /; use Cwd; use MIME::Base64; our $VERSION = '0.01'; CattySession->config( name => 'CattySession', root => cwd . '/t/root', ); CattySession->setup(); sub auto : Private { my ( $self, $context ) = @_; if ( $context->session ) { return 1; } } sub default : Private { my ( $self, $context ) = @_; my $html = html( "Root", "This is the root page" ); $context->response->content_type("text/html"); $context->response->output($html); } sub name : Global { my ($self, $c) = @_; my $html = html( $c->config->{name}, "This is the die page" ); $c->response->content_type("text/html"); $c->response->output($html); } sub html { my ( $title, $body ) = @_; return qq{ $title $body Hello. }; } 1; Test-WWW-Mechanize-Mojo-v0.0.17/scripts000755000764000764 013072365720 20162 5ustar00shlomifshlomif000000000000Test-WWW-Mechanize-Mojo-v0.0.17/scripts/tag-release.pl000444000764000764 71313072365720 23026 0ustar00shlomifshlomif000000000000#!/usr/bin/perl use strict; use warnings; use IO::All; my ($version) = (map { m{\$VERSION *= *'([^']+)'} ? ($1) : () } io->file('lib/Test/WWW/Mechanize/Mojo.pm')->getlines() ) ; if (!defined ($version)) { die "Version is undefined!"; } my @cmd = ( "hg", "tag", "-m", "Tagging the Test-WWW-Mechanize-Mojo release as $version", "releases/$version", ); print join(" ", map { /\s/ ? qq{"$_"} : $_ } @cmd), "\n"; exec(@cmd);