How to do it - lazy building
file: code/LazyBuild/mocked.pl 9: package MockLWP; 10: use Moose; 11: has 'decoded_content' => ( 12: is => 'ro', 13: isa => 'Str', 14: default => '<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE torrent PUBLIC "-//bitTorrent//DTD torrent 0.1//EN" "http://xmlns.ezrss.it/0.1/dtd/"> <rss version="2.0"></rss>', 15: ); 16: has 'is_success' => ( 17: is => 'ro', 18: isa => 'Bool', 19: default => 1, 20: ); 21: 22: sub get { 23: my $self = shift; 24: return $self; 25: }
This is a simple mocked UserAgent that will always return the same string