Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
has_value and has_collection now accept option :extend
- Loading branch information
1 parent
24448e8
commit 5222d8c
Showing
3 changed files
with
54 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
$: << File.expand_path(File.dirname(__FILE__) + '/../lib') | ||
|
||
require 'test/unit' | ||
require 'valuable.rb' | ||
|
||
module BookCollection | ||
end | ||
|
||
module PirateFormatter | ||
def to_pirate | ||
"#{self}, ARRRGGGhhhhh!" | ||
end | ||
end | ||
|
||
class Series < Valuable | ||
has_collection :books, :extend => BookCollection | ||
has_value :name, :extend => PirateFormatter | ||
end | ||
|
||
class ExtendingTest < Test::Unit::TestCase | ||
def test_that_collections_are_extended | ||
assert Series.new.books.is_a?(BookCollection) | ||
end | ||
|
||
def test_that_values_are_extended | ||
assert_equal 'Walk The Plank, ARRRGGGhhhhh!', Series.new(:name => 'Walk The Plank').name.to_pirate | ||
end | ||
|
||
end | ||
|