Created
October 15, 2009 13:26
-
-
Save gsinclair/210946 to your computer and use it in GitHub Desktop.
Demonstrates use of Object#tap in unit testing. Small gain in neatness.
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
class TestTriangle < Test::Unit::TestCase | |
def test_isosceles_given_base_and_height | |
triangle(:ABC, :isosceles, :base => 5, :height :=> 9).tap do |t| | |
assert_point_equal p(2.5,9), t.apex | |
assert_point_equal p(0,0), @register[:A] | |
assert_point_equal p(5,0), @register[:B] | |
assert_point_equal p(2.5,9), @register[:C] | |
assert_equal t, @register.retrieve(:triangle, :ABC) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment