http://qs321.pair.com?node_id=11142249


in reply to Re: I have finally done it; wrote a Tesla API library for Perl!
in thread I have finally done it; wrote a Tesla API library for Perl!

I wrote Mock::Sub several years ago, apparently waiting for this exact problem!

use warnings; use strict; use feature 'say'; use Mock::Sub; use Tesla::Vehicle; my $mock = Mock::Sub->new; my $car = Tesla::Vehicle->new; my $speed_sub = $mock->mock('Tesla::Vehicle::speed'); $speed_sub->return_value(60); # No matter how fast I'm going, we'll always return 60! say $car->speed;