can yo be so kind to explain how the code by Adam Taylor you linked to works?
# dancer code package ip_address_test; use Dancer2; our $VERSION = '0.1'; get '/' => sub { template 'index'; }; get '/ip' => sub { my $ip = $ENV{REMOTE_ADDR} . ""; return "IP == $ip"; }; get '/test' => sub { return "Hello world"; }; get '/env' => sub { use Data::Dumper; #warn Dumper request->env; warn ref request; warn request->remote_address; return request->address; }; true; # test code with monkey patch use strict; use warnings; use ip_address_test; use Test::More tests => 2; use Plack::Test; use HTTP::Request::Common; my $app = ip_address_test->to_app; is( ref $app, 'CODE', 'Got app' ); my $test = Plack::Test->create($app); # overriding the address() method local *Dancer2::Core::Request::address = sub { return '127.0.0.2'; }; my $res = $test->request( GET '/env' ); ok( $res->is_success, '[GET /] successful' ); note $res->decoded_content;
Is this just a way to override the package variable $Dancer2::Core::Request::address with an hardcoded value?

L*

There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

In reply to Re: [Solved] Testing Dancer2 - simulating requests from different IP addresses by Discipulus
in thread [Solved] Testing Dancer2 - simulating requests from different IP addresses by davies

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.