File Coverage

blib/lib/JMAP/Tester/Role/Result.pm
Criterion Covered Total %
statement 17 33 51.5
branch 0 4 0.0
condition 0 3 0.0
subroutine 6 9 66.6
pod 3 3 100.0
total 26 52 50.0


line stmt bran cond sub pod time code
1 11     11   237753 use v5.20.0;
  11         37  
2 11     11   48 use warnings;
  11         17  
  11         645  
3             package JMAP::Tester::Role::Result 0.109;
4             # ABSTRACT: the kind of thing that you get back for a request
5              
6 11     11   473 use Moo::Role;
  11         12022  
  11         58  
7              
8 11     11   5091 use experimental 'signatures';
  11         1190  
  11         69  
9              
10 11     11   4505 use JMAP::Tester::Abort ();
  11         45  
  11         367  
11              
12 11     11   80 use namespace::clean;
  11         29  
  11         146  
13              
14             #pod =head1 OVERVIEW
15             #pod
16             #pod This is the role consumed by the class of any object returned by JMAP::Tester's
17             #pod C method. Its only guarantee, for now, is an C method,
18             #pod and a C method.
19             #pod
20             #pod =cut
21              
22             requires 'is_success';
23             requires 'response_payload';
24              
25             #pod =method assert_successful
26             #pod
27             #pod This method returns the result if it's a success and otherwise aborts.
28             #pod
29             #pod =cut
30              
31 0     0 1   sub assert_successful ($self) {
  0            
  0            
32 0 0         return $self if $self->is_success;
33              
34 0 0 0       my $str = $self->can('has_ident') && $self->has_ident
35             ? $self->ident
36             : "JMAP failure";
37              
38 0           die JMAP::Tester::Abort->new($str);
39             }
40              
41             #pod =method assert_successful_set
42             #pod
43             #pod $result->assert_successful_set($name);
44             #pod
45             #pod This method is equivalent to:
46             #pod
47             #pod $result->assert_successful->sentence_named($name)->as_set->assert_no_errors;
48             #pod
49             #pod C<$name> must be provided.
50             #pod
51             #pod =cut
52              
53 0     0 1   sub assert_successful_set ($self, $name) {
  0            
  0            
  0            
54 0           $self->assert_successful->sentence_named($name)->as_set->assert_no_errors;
55             }
56              
57             #pod =method assert_single_successful_set
58             #pod
59             #pod $result->assert_single_successful_set($name);
60             #pod
61             #pod This method is equivalent to:
62             #pod
63             #pod $result->assert_successful->single_sentence($name)->as_set->assert_no_errors;
64             #pod
65             #pod C<$name> may be omitted, in which case the sentence name is not checked.
66             #pod
67             #pod =cut
68              
69 0     0 1   sub assert_single_successful_set ($self, $name = undef) {
  0            
  0            
  0            
70 0           $self->assert_successful->single_sentence($name)->as_set->assert_no_errors;
71             }
72              
73             1;
74              
75             __END__