Created
July 20, 2012 05:12
-
-
Save ClayShentrup/3148813 to your computer and use it in GitHub Desktop.
Whale question
This file contains hidden or 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
require 'test/unit' | |
class Whale | |
def self.attr_validated(method_name, &validation) | |
# Enter code here to make all tests pass. | |
end | |
attr_validated :num_teeth do |v| | |
v <= 4 | |
end | |
end | |
class TestWhale < Test::Unit::TestCase | |
def test_good_value | |
whale = Whale.new | |
whale.num_teeth = 3 | |
assert_equal 3, whale.num_teeth | |
end | |
def test_nil_value | |
whale = Whale.new | |
assert_raises ArgumentError do | |
whale.num_teeth = nil | |
end | |
end | |
def test_illegal_value | |
whale = Whale.new | |
assert_raises ArgumentError do | |
whale.num_teeth = 5 | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment