From Code to Community: Sponsoring The Perl and Raku Conference 2025 Learn more

#!/perl
use strict;
use File::Temp qw/ tempdir /;
use Test::More 'no_plan';
my $expected_content = "<title>Google</title>";
ok( my $fetch = App::Wubot::Reactor::WebFetch->new(),
"Creating new WebFetch reactor object"
);
{
ok( my $results = $fetch->react( { title => 'test' },
field => 'body',
} ),
"Calling fetch for 'body' field from google"
);
like( $results->{body},
qr/$expected_content/i,
"Checking that body field contains google content"
);
}
{
ok( my $results = $fetch->react( { title => 'test',
},
{ url_field => 'myurl',
field => 'body',
} ),
"Calling fetch for 'body' field from url on field myurl"
);
like( $results->{body},
qr/$expected_content/i,
"Checking that body field contains google content"
);
}