Created
June 11, 2012 19:22
-
-
Save reneedv/2912109 to your computer and use it in GitHub Desktop.
Wine Glass Homework 1
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
# Make the existing tests pass. | |
# Add 2 more tests and methods for: | |
## 1. Another print method for material, volume, and stem_length all together | |
## 2. A method that calculates and returns the percent of the glass that is full when you pass in the | |
### volume of liquid in the glass. | |
### This calculation is: (volume_passed_to_method / volume_of_wine_glass) * 100 | |
class WineGlass | |
attr_accessor :material, :volume, :stem_length | |
def pretty_print_material | |
"Happy Dance Party : #{self.material}" | |
end | |
end | |
require 'minitest/autorun' | |
class TestWineGlass < MiniTest::Unit::TestCase | |
def setup | |
@wg = WineGlass.new | |
@wg.material = 'wood' | |
@wg.volume = 650 | |
@wg.stem_length = 5 | |
end | |
def test_that_wine_glasses_have_volume | |
assert_respond_to @wg, :volume | |
end | |
def test_that_wg_has_a_pretty_print_for_material | |
assert_equal "Material : #{@wg.material}", @wg.pretty_print_material | |
end | |
def test_wg_pretty_prints_stem_length_and_volume | |
assert_equal "This wine glass is cool. It has a stem length of 5 and a volume of 650ml", @wg.pretty_print_stuff | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Make the existing tests pass.
Add 2 more tests and methods for:
1. Another print method for material, volume, and stem_length all together
2. A method that calculates and returns the percent of the glass that is full when you pass in the
volume of liquid in the glass.
This calculation is: (volume_passed_to_method / volume_of_wine_glass) * 100
class WineGlass
attr_accessor :material, :volume, :stem_length, :volume_of_wine
def pretty_print_material
"Material : #{self.material}"
end
end
require 'minitest/autorun'
class TestWineGlass < MiniTest::Unit::TestCase
end