Skip to content

Instantly share code, notes, and snippets.

@RedSoxFan22
Created May 20, 2015 13:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RedSoxFan22/c556f255586a73cf3805 to your computer and use it in GitHub Desktop.
Save RedSoxFan22/c556f255586a73cf3805 to your computer and use it in GitHub Desktop.
Goats
require 'minitest/autorun'
require 'minitest/pride'
require './may.rb'
class Goat
attr_reader :name
def initialize(name)
end
def send(message)
"I hate cats!"
end
def name
@name
end
def number_of_legs
return 4
end
end
class ClassesChallenge < MiniTest::Test
def test_class_exists
assert Goat
end
def test_initialize
assert Goat.new("Windsong")
end
def test_reader
amalthea = Goat.new("Amalthea")
assert_equal "Amalthea", amalthea.name
assert_raises(NoMethodError) do
amalthea.name = "Djali"
end
end
def test_private
billy = Goat.new("Billy Whiskers")
assert_raises(NoMethodError) do
billy.hate_cats
end
assert_equal "I hate cats!", billy.send(:hate_cats)
end
def test_class
assert_equal 4, Goat.number_of_legs
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment