| File: | t/request-parameter.t |
| Coverage: | 100.0% |
| line | stmt | bran | cond | sub | pod | time | code |
|---|---|---|---|---|---|---|---|
| 1 | #!/usr/bin/env perl -w | ||||||
| 2 | 1 1 1 | 100 9 10 | use strict; | ||||
| 3 | 1 1 1 | 9 3 10 | use warnings; | ||||
| 4 | 1 1 1 | 106 5 17 | use Test::More tests => 2; | ||||
| 5 | 1 1 1 | 85 6 5 | use Moose (); | ||||
| 6 | |||||||
| 7 | package SomeController; | ||||||
| 8 | 1 1 1 | 114 5 13 | use Railsish::Controller; | ||||
| 9 | 1 1 1 | 10 4 19 | use Test::More; | ||||
| 10 | |||||||
| 11 | sub stuff { | ||||||
| 12 | 1 1 | 4 8 | my %params = %{params()}; | ||||
| 13 | 1 | 12 | is( $params{controller}, "some" ); | ||||
| 14 | 1 | 8 | is( $params{action}, "stuff" ); | ||||
| 15 | } | ||||||
| 16 | |||||||
| 17 | package main; | ||||||
| 18 | |||||||
| 19 | 1 1 1 | 91 6 16 | use Railsish::Router; | ||||
| 20 | 1 1 1 | 88 5 20 | use Railsish::Dispatcher; | ||||
| 21 | 1 1 1 | 77 6 17 | use HTTP::Engine; | ||||
| 22 | 1 1 1 | 86 4 18 | use HTTP::Request; | ||||
| 23 | |||||||
| 24 | Railsish::Router->draw( | ||||||
| 25 | sub { | ||||||
| 26 | 1 | 6 | my ($map) = @_; | ||||
| 27 | 1 | 9 | $map->connect("/:controller/:action"); | ||||
| 28 | } | ||||||
| 29 | 1 | 28 | ); | ||||
| 30 | |||||||
| 31 | my $engine = HTTP::Engine->new( | ||||||
| 32 | interface => { | ||||||
| 33 | module => "Test", | ||||||
| 34 | request_handler => sub { | ||||||
| 35 | 1 | 37 | Railsish::Dispatcher->dispatch(@_); | ||||
| 36 | } | ||||||
| 37 | } | ||||||
| 38 | 1 | 29 | ); | ||||
| 39 | |||||||
| 40 | 1 | 77 | my $response = $engine->run(HTTP::Request->new(GET => "/some/stuff")); | ||||
| 41 | |||||||