Skip to content

Instantly share code, notes, and snippets.

@reneedv
Forked from brookr/table.rb
Created May 31, 2012 20:02
Show Gist options
  • Save reneedv/2845858 to your computer and use it in GitHub Desktop.
Save reneedv/2845858 to your computer and use it in GitHub Desktop.
A basic Table class
# Assignment: Fill in this Table class so the tests pass!
# Exercise Details:
#- Make a Table object class
#- Define at least 5 properties of a Table (legs, material, items_on_it, etc…)
#- Define an initialize method that sets one or more of the attributes when you call Table.new
#- Define a pretty_print method that prints out some useful information about your table
#- Email us a link to your code in a Gist
# Extra Credit:
#- Make tests for your Table class
# - Try the Exercises in the Gist for the Book class
class Table
end
# Unit tests
require 'minitest/autorun'
class TestTable < MiniTest::Unit::TestCase
def setup
@table = Table.new(color: "brown", seats: 4)
end
def test_that_table_has_color
assert_equal "brown", @table.color
end
def test_that_table_has_seats
assert_equal 4, @table.seats
end
def test_that_table_can_print_pretty
assert_equal "The #{@table.color} can seat #{@table.seats}", @table.pretty_print
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment