Created
September 21, 2015 13:40
-
-
Save TylerRockwell/1808104d00945cf4cd1b to your computer and use it in GitHub Desktop.
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
require 'minitest/autorun' | |
require 'minitest/pride' | |
#I somehow overlooked this challenge. Submitting now on 9-21 | |
class Goat | |
attr_reader :name | |
def initialize(name) | |
@name = name | |
end | |
def self.number_of_legs | |
4 | |
end | |
private def hate_cats | |
"I hate cats!" | |
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