Skip to content

Instantly share code, notes, and snippets.

@mikedao
Created March 29, 2018 21:04
Show Gist options
  • Save mikedao/3ea03213babb50acf31f8fec8ccf5fa9 to your computer and use it in GitHub Desktop.
Save mikedao/3ea03213babb50acf31f8fec8ccf5fa9 to your computer and use it in GitHub Desktop.
require "minitest/autorun"
require "minitest/pride"
require "./lib/patron"
class PatronTest < Minitest::Test
def test_patron_has_attributes
patron = Patron.new("Bob")
assert_equal "Bob", patron.name
assert_equal [], patron.interests
end
def test_patron_can_add_interests
patron = Patron.new("Bob")
assert_equal [], patron.interests
patron.add_interest("Pizza")
patron.add_interest("Dumplings")
expected = ["Pizza", "Dumplings"]
assert_instance_of Array, patron.interests
assert_equal 2, patron.interests.count
assert_equal expected, patron.interests
end
end
require "minitest/autorun"
require "minitest/pride"
require "./lib/museum"
class MuseumTest < Minitest::Test
def test_it_has_name
museum = Museum.new("Art")
assert_equal "Art", museum.name
end
def test_it_can_have_exhibits
museum = Museum.new("Art")
museum.add_exhibit("Ice Cream", 10)
assert_equal ({"Ice Cream" => 10}), museum.exhibits
end
def test_it_can_have_many_exhibits
museum = Museum.new("Art")
museum.add_exhibit("Ice Cream", 10)
museum.add_exhibit("Cannoli", 20)
museum.add_exhibit("Twinkies", 5)
expected = {"Ice Cream" => 10,
"Cannoli" => 20,
"Twinkies" => 5}
assert_equal expected, museum.exhibits
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment