PageRenderTime 44ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/t/TestApp/t/20-error-pages.t

https://github.com/gitpan/Jifty
Perl | 59 lines | 48 code | 9 blank | 2 comment | 1 complexity | 406a33896047d81d41a40ab5792f529d MD5 | raw file
Possible License(s): JSON
  1. #!/usr/bin/env perl
  2. use warnings;
  3. use strict;
  4. =head1 DESCRIPTION
  5. Tests that error pages work
  6. =cut
  7. use Jifty::Test::Dist tests => 1 + 2 * 29;
  8. use Jifty::Test::WWW::Mechanize;
  9. my $URL = Jifty::Test->make_server->started_ok;
  10. my $mech = Jifty::Test::WWW::Mechanize->new;
  11. for my $path ("", "/td") {
  12. my $prefix = "$URL$path";
  13. $mech->get_ok("$prefix/template-with-error");
  14. $mech->warnings_like(qr/Can't locate object method "non_existent_method" via package "Jifty::Web"/);
  15. $mech->base_like(qr{errors/500}, "End up on error page");
  16. $mech->content_like(qr/something went awry/i, "Have error header");
  17. $mech->content_like(qr/locate object method .*?non_existent_method.*?/, "Have error itself, if in devel mode");
  18. $mech->content_like(qr/template-with-error/, "Have stack trace");
  19. $mech->content_unlike(qr/Before error/, "Don't have content from before error");
  20. $mech->content_unlike(qr/After error/, "Don't have content from after error");
  21. ok($mech->continuation, "Have a continuation");
  22. ok($mech->continuation->response->error, "Have an error set");
  23. isa_ok($mech->continuation->response->error, "HTML::Mason::Exception", "Error is a reference");
  24. # Region itself gets full page wrapper if it's the only request
  25. $mech->get_ok("$prefix/region-with-error", "Request region (no wrapper!) with error");
  26. $mech->warnings_like(qr/Can't locate object method "non_existent_method" via package "Jifty::Web"/);
  27. $mech->base_like(qr{errors/500}, "End up at error page");
  28. $mech->content_like(qr/something went awry/i, "Have error header");
  29. $mech->content_like(qr/locate object method .*?non_existent_method.*?/, "Have error itself, if in devel mode");
  30. $mech->content_like(qr/region-with-error/, "Have stack trace");
  31. $mech->content_unlike(qr/Region before/, "Don't have content from before error");
  32. $mech->content_unlike(qr/Region after/, "Don't have content from after error");
  33. # If it's a subrequest, don't nest wrappers
  34. $mech->get_ok("$prefix/call-region-with-error");
  35. $mech->warnings_like(qr/Can't locate object method "non_existent_method" via package "Jifty::Web"/);
  36. $mech->base_unlike(qr{errors/500}, "Doesn't redirect if only a region error");
  37. #$mech->content_unlike(qr/something went awry/i, "Doesn't have error header");
  38. #warn $mech->content;
  39. $mech->content_like(qr/<h2>Call stack<\/h2>/i, "Doesn't have error header");
  40. $mech->content_like(qr/locate object method .*?non_existent_method.*?/, "Has error itself, if in devel mode");
  41. $mech->content_like(qr/region-with-error/, "Have stack trace");
  42. $mech->content_like(qr/Calling before/, "Does have region content from before error");
  43. $mech->content_like(qr/Region before/, "Does have calling content from before error"); # TODO: change?
  44. $mech->content_unlike(qr/Region after/, "Don't have region content from after error");
  45. $mech->content_like(qr/Calling after/, "Does have calling content from after error");
  46. }
  47. 1;