If you think that it's not detecting the browser, then run this test. If everything's OK, then it should return "default is a browser".
#!/usr/bin/perl
use strict;
use warnings;
use Test::More;
use Catalyst::Request;
use Catalyst::TraitFor::Request::REST::ForBrowsers;
use Catalyst::Request::REST::ForBrowsers;
use Catalyst::Action::REST::ForBrowsers;
use Moose::Meta::Class;
use HTTP::Headers;
my $anon_class = Moose::Meta::Class->create_anon_class(
superclasses => ['Catalyst::Request'],
roles => ['Catalyst::TraitFor::Request::REST::ForBrowsers']
+,
cache => 1,
)->name;
for my $class ( $anon_class, 'Catalyst::Request::REST::ForBrowsers' )
+{
{
for my $method (qw( GET )) {
my $req = $class->new();
$req->method($method);
$req->{_context} = 'MockContext';
$req->parameters( {} );
is(
$req->method(), $method,
);
}
}
{
my $req = $class->new();
$req->{_context} = 'MockContext';
$req->method('GET');
$req->parameters( {} );
$req->headers( HTTP::Headers->new() );
ok( $req->looks_like_browser(), 'default is a browser' );
}
package MockContext;
sub prepare_body { }
}
done_testing;
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|