Subject: | with() function with class methods/imported subroutines |
with() does not work now as one can expect when mocking plain function (not object methods).
Seems it strips first argument, as expects it to be $self
package A;
sub mysub
{
}
package B;
@ISA = qw(A);
sub t
{
mysub('123');
}
package main;
use strict;
use warnings;
use Test::Spec;
describe "test1" => sub {
it "should work using with()" => sub {
B->expects("mysub")->with(123);
B::t();
};
it "should work using returns()" => sub {
B->expects("mysub")->returns(sub { is shift, 123 });
B::t();
};
};
runtests unless caller;
__END__
not ok 1 - test1 should work using with()
# Failed test 'test1 should work using with()' by dying:
# Number of arguments don't match expectation
# at /usr/local/share/perl/5.10.1/Test/Spec/Mocks.pm line 434.
ok 2 - test1 should work using returns()
1..2
# Looks like you failed 1 test of 2.