Skip to content

Instantly share code, notes, and snippets.

@novohispano
Last active July 11, 2016 14:51
Show Gist options
  • Save novohispano/ec38e8ffaa489a836cb2b43efac3e48d to your computer and use it in GitHub Desktop.
Save novohispano/ec38e8ffaa489a836cb2b43efac3e48d to your computer and use it in GitHub Desktop.
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
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