Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## BoyosPlace::Email
- package BoyosPlace::Email;
- use Moose;
- use Email::Stuff;
- use Email::Valid;
- has 'subject' => ( is => 'ro', isa => "String" );
- has 'to' => ( is => 'ro', isa => "Email::Valid", default => sub { Email::Valid->address(shift) } );
- has 'from' => ( is => 'ro', isa => "Email::Valid", default => sub { Email::Valid->address(shift) } );
- has 'data' => ( is => 'ro', isa => "String" );
- has 'cc' => ( is => 'ro', isa => "String" );
- has 'email' => ( is => 'ro', isa => "Email::Stuff",
- default => sub {
- my $self = shift;
- Email::Stuff->new(
- from =>$self->from,
- to =>$self->to,
- cc =>$self->cc,
- subject =>$self->subject,
- text_body =>$self->text_body
- );
- },
- lazy =>1,
- );
- sub send {
- my $self = shift;
- $self->email->send;
- }
- no Moose;
- __PACKAGE__->meta->make_immutable;
- 1;
- ## email.t
- use Test::More tests => 1;
- use FindBin;
- use lib "$FindBin::Bin/../lib";
- use BoyosPlace::Email;
- my $email = BoyosPlace::Email->new(
- to => "dhoss@cpan.org",
- from => "devin.austin@gmail.com",
- subject => "testing",
- data => "testing zee test",
- );
- ok( $email->send, "Email sent ok");
- ## failing with:
- devin@devin-laptop:~/web-devel/boyosplace$ prove -l t/email.t
- t/email.t .. Attribute (to) does not pass the type constraint because: Validation failed for 'Email::Valid' failed with value dhoss.org at t/email.t line 6
- # Looks like your test exited with 255 before it could output anything.
- t/email.t .. Dubious, test returned 255 (wstat 65280, 0xff00)
- Failed 1/1 subtests
- Test Summary Report
- -------------------
- t/email.t (Wstat: 65280 Tests: 0 Failed: 0)
- Non-zero exit status: 255
- Parse errors: Bad plan. You planned 1 tests but ran 0.
- Files=1, Tests=0, 0 wallclock secs ( 0.03 usr 0.01 sys + 0.40 cusr 0.05 csys = 0.49 CPU)
- Result: FAIL
Add Comment
Please, Sign In to add comment