Hi

How to you approach testing ajax calls?


If I had:
use  Dancer::Plugin::Ajax;


ajax '/somedata.json' =>  sub {
    return { data => "hello" };
};


The tests:
route_exists [ 'GET' => '/somedata.json'], 'a route handler is defined for /somedata';
response_status_is ['GET' => '/somedata.json'], 200, 'response status is 200 for /somedata';


give:
1..2
ok 1
not ok 2 - response status is 200 for /
#   Failed test 'response status is 200 for /'
#   at t/003_api_route.t line 10.
#          got: '404'
#     expected: '200'
# Looks like you failed 1 test of 2.

So how do I construct the response_status_is to be:   X-Requested-With: XMLHttpRequest

And secondly the route_exists call would also match:

get '/somedata.json' =>  sub {
    return { data => "hello" };
};

so how do I distinguish between a GET and an AJAX call with a route_exists?

Thanks for any pointers.