File: 04_api.t

package info (click to toggle)
libdancer-perl 1.3202%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 2,408 kB
  • ctags: 638
  • sloc: perl: 7,215; xml: 1,977; sh: 51; makefile: 29; sql: 5
file content (33 lines) | stat: -rw-r--r-- 1,061 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use Test::More import => ['!pass'];
use Dancer ':syntax';
use Dancer::Session::YAML;

plan tests => '4';

use File::Spec;
use lib File::Spec->catdir( 't', 'lib' );
use EasyMocker;

my $fake_session = bless { foo => 42 }, 'Dancer::Session::YAML';

mock 'Dancer::Session'
    => method 'get_current_session' => should sub { $fake_session };
mock 'Dancer::Session::YAML'
    => method 'init' => should sub { 1 };
mock 'Dancer::Session::YAML'
    => method 'create' => should sub { $fake_session };
mock 'Dancer::Session::YAML'
    => method 'retrieve' => should sub { $fake_session };
mock 'Dancer::Session::YAML'
    => method 'flush' => should sub { $fake_session };
mock 'Dancer::Session::YAML'
    => method 'destroy' => should sub { $fake_session };

ok(set(session => 'YAML'), "set session engine to 'YAML'");

is session('foo'), 42, 'session reader works';
ok session('foo' => 54), 'session writer works';

my $expected = bless { foo => 54 }, 'Dancer::Session::YAML';
is_deeply session(), $expected, 
    "session object is returned when no args is given";