1#!/usr/bin/perl 2use strict; 3use warnings; 4use Test::More qw(no_plan); 5use FindBin; 6use lib "$FindBin::Bin/../lib"; 7 8BEGIN { 9 use_ok "Zen::Koan"; 10} 11 12Create_Koan: { 13 my $k = Zen::Koan->new( title => 'foo', body => 'bar' ); 14 isa_ok $k, 'Zen::Koan'; 15 is $k->title, 'foo'; 16 is $k->body, 'bar'; 17 is $k->as_html, <<EOT; 18<div id='koan_title'>foo</div> 19<div id='koan_body'> 20<p>bar</p> 21</div> 22EOT 23} 24 25Create_by_hashref: { 26 my $k = Zen::Koan->new( { title => 'foo' } ); 27 isa_ok $k, 'Zen::Koan'; 28 is $k->title, 'foo'; 29} 30 31Multi_paragraph_koan: { 32 my $body = "this\nand that\n\nand others.\n"; 33 my $k = Zen::Koan->new( title => 'foo', 34 body => $body, 35 ); 36 isa_ok $k, 'Zen::Koan'; 37 is $k->title, 'foo'; 38 is $k->body, $body; 39 is $k->as_html, <<EOT; 40<div id='koan_title'>foo</div> 41<div id='koan_body'> 42<p>this</p> 43<p>and that</p> 44<p>and others.</p> 45</div> 46EOT 47} 48 49sub poem_koan { Zen::Koan->new( body => <<EOK ) } 50Here is my poem: 51 No more water in the pail! 52 No more moon in the water! 53That is my poem. 54EOK 55 56Koan_with_poem: { 57 my $k = poem_koan(); 58 is $k->as_html, <<EOK; 59<div id='koan_title'>A koan by no other name</div> 60<div id='koan_body'> 61<p>Here is my poem:</p> 62<blockquote> 63<p>No more water in the pail!</p> 64<p>No more moon in the water!</p> 65</blockquote> 66<p>That is my poem.</p> 67</div> 68EOK 69} 70 71Koan_as_text: { 72 my $k = poem_koan(); 73 is $k->as_text, <<EOK; 74 A koan by no other name 75 76Here is my poem: 77 No more water in the pail! 78 No more moon in the water! 79That is my poem. 80EOK 81} 82 83Less_specified_koans: { 84 my $k = Zen::Koan->new; 85 isa_ok $k, 'Zen::Koan'; 86 is $k->title, 'A koan by no other name'; 87 is $k->body, 'This koan offers little wisdom. It just is.'; 88} 89 90Other_functions: { 91 my $k = Zen::Koan->new; 92 isa_ok $k, 'Zen::Koan'; 93 like $k->underlying_meaning, qr#You are expecting too much#; 94} 95 96