Skip to content

Commit

Permalink
Add as_text
Browse files Browse the repository at this point in the history
git-svn-id: http://5thplane.com/svn/perl/Zen-Koans@120 e5f7e8ef-ac07-0410-9fef-9965b2c2b5fc
  • Loading branch information
lukec committed Mar 7, 2006
1 parent 0fc8711 commit 9b5ede1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
5 changes: 5 additions & 0 deletions lib/Zen/Koan.pm
Expand Up @@ -65,6 +65,11 @@ $body</div>
EOT
}

sub as_text {
my $self = shift;
return "\t$self->{title}\n\n$self->{body}";
}

sub AUTOLOAD {
return <<EOT
You are expecting too much from this koan.
Expand Down
18 changes: 16 additions & 2 deletions t/koan.t
Expand Up @@ -46,13 +46,15 @@ Multi_paragraph_koan: {
EOT
}

Koan_with_poem: {
my $k = Zen::Koan->new( body => <<EOK );
sub poem_koan { Zen::Koan->new( body => <<EOK ) }
Here is my poem:
No more water in the pail!
No more moon in the water!
That is my poem.
EOK

Koan_with_poem: {
my $k = poem_koan();
is $k->as_html, <<EOK;
<div id='koan_title'>A koan by no other name</div>
<div id='koan_body'>
Expand All @@ -66,6 +68,18 @@ EOK
EOK
}

Koan_as_text: {
my $k = poem_koan();
is $k->as_text, <<EOK;
A koan by no other name
Here is my poem:
No more water in the pail!
No more moon in the water!
That is my poem.
EOK
}

Less_specified_koans: {
my $k = Zen::Koan->new;
isa_ok $k, 'Zen::Koan';
Expand Down

0 comments on commit 9b5ede1

Please sign in to comment.