@@ -91,4 +91,51 @@ subtest 'attr_is' => sub {
91
91
is_deeply \@args , [' is' , ' test' , ' wrong' , ' some description' ], ' right result' ;
92
92
};
93
93
94
+ subtest ' header_exists' => sub {
95
+ $t -> header_exists(' Content-Type' );
96
+ is_deeply \@args , [' ok' , 1, ' header "Content-Type" exists' ], ' right result' ;
97
+ $t -> header_exists(' Content-Type' , ' some description' );
98
+ is_deeply \@args , [' ok' , 1, ' some description' ], ' right result' ;
99
+ };
100
+
101
+ subtest ' header_exists_not' => sub {
102
+ $t -> header_exists_not(' X-Exists-Not' );
103
+ is_deeply \@args , [' ok' , 1, ' no "X-Exists-Not" header' ], ' right result' ;
104
+ $t -> header_exists_not(' X-Exists-Not' , ' some description' );
105
+ is_deeply \@args , [' ok' , 1, ' some description' ], ' right result' ;
106
+ };
107
+
108
+ subtest ' header_is' => sub {
109
+ $t -> header_is(' Content-Type' , ' text/html;charset=UTF-8' );
110
+ is_deeply \@args ,
111
+ [' is' , ' text/html;charset=UTF-8' , ' text/html;charset=UTF-8' , ' Content-Type: text/html;charset=UTF-8' ],
112
+ ' right result' ;
113
+ $t -> header_is(' Content-Type' , ' text/html;charset=UTF-8' , ' some description' );
114
+ is_deeply \@args , [' is' , ' text/html;charset=UTF-8' , ' text/html;charset=UTF-8' , ' some description' ], ' right result' ;
115
+ };
116
+
117
+ subtest ' header_isnt' => sub {
118
+ $t -> header_isnt(' Content-Type' , ' image/png' );
119
+ is_deeply \@args , [' isnt' , ' text/html;charset=UTF-8' , ' image/png' , ' not Content-Type: image/png' ], ' right result' ;
120
+ $t -> header_isnt(' Content-Type' , ' image/png' , ' some description' );
121
+ is_deeply \@args , [' isnt' , ' text/html;charset=UTF-8' , ' image/png' , ' some description' ], ' right result' ;
122
+ };
123
+
124
+ subtest ' header_like' => sub {
125
+ $t -> header_like(' Content-Type' , qr / text\/ html;charset=UTF-8/ );
126
+ is_deeply \@args , [' like' , ' text/html;charset=UTF-8' , qr / text\/ html;charset=UTF-8/ , ' Content-Type is similar' ],
127
+ ' right result' ;
128
+ $t -> header_like(' Content-Type' , qr / text\/ html;charset=UTF-8/ , ' some description' );
129
+ is_deeply \@args , [' like' , ' text/html;charset=UTF-8' , qr / text\/ html;charset=UTF-8/ , ' some description' ],
130
+ ' right result' ;
131
+ };
132
+
133
+ subtest ' header_unlike' => sub {
134
+ $t -> header_unlike(' Content-Type' , qr / image\/ png/ );
135
+ is_deeply \@args , [' unlike' , ' text/html;charset=UTF-8' , qr / image\/ png/ , ' Content-Type is not similar' ],
136
+ ' right result' ;
137
+ $t -> header_unlike(' Content-Type' , qr / image\/ png/ , ' some description' );
138
+ is_deeply \@args , [' unlike' , ' text/html;charset=UTF-8' , qr / image\/ png/ , ' some description' ], ' right result' ;
139
+ };
140
+
94
141
done_testing();
0 commit comments