| 1 | package Test::BDD::Cucumber::Definitions::HTTP::In; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | use utf8; | ||
| 6 | |||
| 7 | use Test::BDD::Cucumber::Definitions qw(C Given When Then); | ||
| 8 | use Test::BDD::Cucumber::Definitions::HTTP qw(HTTP); | ||
| 9 | |||
| 10 | our $VERSION = '0.41'; | ||
| 11 | |||
| 12 | ## no critic [RegularExpressions::ProhibitCaptureWithoutTest] | ||
| 13 | ## no critic [RegularExpressions::RequireExtendedFormatting] | ||
| 14 | ## no critic [RegularExpressions::ProhibitComplexRegexes] | ||
| 15 | |||
| 16 | sub import { | ||
| 17 | |||
| 18 | # http request header "(.+?)" set "(.*)" | ||
| 19 | Given qr/http request header "(.+?)" set "(.*)"/, sub { | ||
| 20 | HTTP->request_header_set( $1, $2 ); | ||
| 21 | }; | ||
| 22 | |||
| 23 | # http request content set | ||
| 24 | Given qr/http request content set/, sub { | ||
| 25 | HTTP->request_content_set( C->data() ); | ||
| 26 | }; | ||
| 27 | |||
| 28 | # http request "(.+?)" send "(.+)" | ||
| 29 | When qr/http request "(.+?)" send "(.+)"/, sub { | ||
| 30 | HTTP->request_send( $1, $2 ); | ||
| 31 | }; | ||
| 32 | |||
| 33 | # http response code eq "(.+)" | ||
| 34 | Then qr/http response code eq "(.+)"/, sub { | ||
| 35 | HTTP->response_code_eq($1); | ||
| 36 | }; | ||
| 37 | |||
| 38 | # http response header "(.+?)" eq "(.*)" | ||
| 39 | Then qr/http response header "(.+?)" eq "(.*)"/, sub { | ||
| 40 | HTTP->response_header_eq( $1, $2 ); | ||
| 41 | }; | ||
| 42 | |||
| 43 | # http response header "(.+?)" re "(.+)" | ||
| 44 | Then qr/http response header "(.+?)" re "(.+)"/, sub { | ||
| 45 | HTTP->response_header_re( $1, $2 ); | ||
| 46 | }; | ||
| 47 | |||
| 48 | # http response content eq "(.*)" | ||
| 49 | Then qr/http response content eq "(.*)"/, sub { | ||
| 50 | HTTP->response_content_eq($1); | ||
| 51 | }; | ||
| 52 | |||
| 53 | # http response content re "(.+)" | ||
| 54 | Then qr/http response content re "(.+)"/, sub { | ||
| 55 | HTTP->response_content_re($1); | ||
| 56 | }; | ||
| 57 | |||
| 58 | return; | ||
| 59 | } | ||
| 60 | |||
| 61 | 1; |