Last active
July 11, 2016 14:51
-
-
Save novohispano/ec38e8ffaa489a836cb2b43efac3e48d to your computer and use it in GitHub Desktop.
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
class Pony | |
attr_accessor :hungry | |
def initialize | |
@hungry = true | |
end | |
def legs | |
4 | |
end | |
def head | |
1 | |
end | |
def hungry? | |
hungry | |
end | |
def eats | |
@hungry = false | |
end | |
end |
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 './pony' | |
require 'minitest/autorun' | |
require 'minitest/pride' | |
class PonyTest < Minitest::Test | |
def test_it_has_four_legs | |
pony = Pony.new | |
assert_equal 4, pony.legs | |
end | |
def test_it_has_one_head | |
pony = Pony.new | |
assert_equal 1, pony.head | |
end | |
def test_it_is_hungry_when_it_is_born | |
pony = Pony.new | |
assert_equal true, pony.hungry? | |
end | |
def test_it_can_eat | |
pony = Pony.new | |
assert_respond_to(pony, :eats) | |
end | |
def test_it_is_no_longer_hungry_when_he_eats | |
pony = Pony.new | |
assert_equal true, pony.hungry? | |
pony.eats | |
assert_equal false, pony.hungry? | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment