Guest User

Untitled

a guest
Jun 18th, 2018
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.13 KB | None | 0 0
  1. ## BoyosPlace::Email
  2. package BoyosPlace::Email;
  3.  
  4. use Moose;
  5. use Email::Stuff;
  6. use Email::Valid;
  7.  
  8. has 'subject' => ( is => 'ro', isa => "String" );
  9. has 'to' => ( is => 'ro', isa => "Email::Valid", default => sub { Email::Valid->address(shift) } );
  10. has 'from' => ( is => 'ro', isa => "Email::Valid", default => sub { Email::Valid->address(shift) } );
  11. has 'data' => ( is => 'ro', isa => "String" );
  12. has 'cc' => ( is => 'ro', isa => "String" );
  13. has 'email' => ( is => 'ro', isa => "Email::Stuff",
  14. default => sub {
  15. my $self = shift;
  16. Email::Stuff->new(
  17. from =>$self->from,
  18. to =>$self->to,
  19. cc =>$self->cc,
  20. subject =>$self->subject,
  21. text_body =>$self->text_body
  22. );
  23. },
  24. lazy =>1,
  25. );
  26.  
  27.  
  28. sub send {
  29. my $self = shift;
  30.  
  31. $self->email->send;
  32.  
  33. }
  34.  
  35.  
  36. no Moose;
  37.  
  38. __PACKAGE__->meta->make_immutable;
  39. 1;
  40.  
  41. ## email.t
  42. use Test::More tests => 1;
  43. use FindBin;
  44. use lib "$FindBin::Bin/../lib";
  45. use BoyosPlace::Email;
  46.  
  47. my $email = BoyosPlace::Email->new(
  48. to => "dhoss@cpan.org",
  49. from => "devin.austin@gmail.com",
  50. subject => "testing",
  51. data => "testing zee test",
  52. );
  53.  
  54. ok( $email->send, "Email sent ok");
  55.  
  56. ## failing with:
  57. devin@devin-laptop:~/web-devel/boyosplace$ prove -l t/email.t
  58. 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
  59. # Looks like your test exited with 255 before it could output anything.
  60. t/email.t .. Dubious, test returned 255 (wstat 65280, 0xff00)
  61. Failed 1/1 subtests
  62.  
  63. Test Summary Report
  64. -------------------
  65. t/email.t (Wstat: 65280 Tests: 0 Failed: 0)
  66. Non-zero exit status: 255
  67. Parse errors: Bad plan. You planned 1 tests but ran 0.
  68. Files=1, Tests=0, 0 wallclock secs ( 0.03 usr 0.01 sys + 0.40 cusr 0.05 csys = 0.49 CPU)
  69. Result: FAIL
Add Comment
Please, Sign In to add comment