summary refs log tree commit diff
path: root/t/01_basic.t
blob: 471f3dd487a165bc388b2d5868e6f3845999ce62 (plain) (blame)
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
34
35
use strict;
use warnings;
use Test::More;
use Test::Exception;
use lib ('t/lib');
use FakeAPI;

my $obj = FakeAPI->new;
ok $obj, "... object created";
ok $obj->meta->has_attribute('useragent'),
    "... useragent attribute have been added";

ok my $method = $obj->meta->find_method_by_name('bar'),
    '... method bar have been created';

ok $method->meta->has_attribute('path'), '... method bar have attribute path';

throws_ok { $obj->baz } qr/bla is declared as required, but is not present/,
    "... check required params";

throws_ok {
    $obj->bar( bar => 1, );
}
qr/baz is declared as required, but is not present/,
    "... check required params are present";

throws_ok {
    $obj->bar( bar => 1, foo => 2, );
}
qr/foo is not declared as a param/, "... check declared params";

ok my @methods = $obj->meta->local_api_methods(), '... get api methods';
is scalar @methods, 3, '... got 3 methods in our API';

done_testing;