PrePAN

Sign in to PrePAN

Module::Spy jasmine(JS library) like spy library for Perl5

Good

Synopsis

Spy for class method.

    use Module::Spy;

    my $spy = spy('LWP::UserAgent', 'request');
    $spy->returns(HTTP::Response->new(200));

    my $res = LWP::UserAgent->new()->get('http://mixi.jp/');

Spy for object method

    use Module::Spy;

    my $ua = LWP::UserAgent->new();
    my $spy = spy($ua, 'request')->returns(HTTP::Response->new(200));

    my $res = $ua->get('http://mixi.jp/');

    ok $spy->called;

Description

This is a library for spying. Main purpose is testing. It's inspired from jasmine javascript library(http://jasmine.github.io/).

Points

  • Spy class methods and object methods.
  • Cool interface

Comments

I know about Sub::Spy. But I want to spy class method/instance method

Please sign up to post a review.