Skip to content

Instantly share code, notes, and snippets.

@justincampbell
Created March 8, 2015 02:25
Show Gist options
  • Save justincampbell/a589b0ad1c4af2cb0177 to your computer and use it in GitHub Desktop.
Save justincampbell/a589b0ad1c4af2cb0177 to your computer and use it in GitHub Desktop.
class Game
attr_accessor :home
attr_accessor :away
def initialize(home, away)
@home = home
@away = away
end
def city
@home.city
end
end
class Team
attr_accessor :name
attr_accessor :city
def initialize(city, name)
@name = name
@city = city
end
end
gem 'minitest'
require 'minitest/autorun'
require_relative 'scorer'
class GameTest < MiniTest::Test
def test_game
home = Team.new("Philadelphia", "Eagles")
away = Team.new("New York", "Giants")
game = Game.new(home, away)
assert_equal game.home.name, "Eagles"
assert_equal game.away.name, "Giants"
assert_equal "Philadelphia", game.city
end
end
class TeamTest < MiniTest::Test
def test_team_name
team = Team.new("Atlanta", "Falcons")
assert_equal "Atlanta", team.city
assert_equal "Falcons", team.name
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment