Skip to content

Instantly share code, notes, and snippets.

@RyanSnodgrass
Last active August 29, 2015 13:59
Show Gist options
  • Select an option

  • Save RyanSnodgrass/10648157 to your computer and use it in GitHub Desktop.

Select an option

Save RyanSnodgrass/10648157 to your computer and use it in GitHub Desktop.
#take out trash
require 'rspec'
class KitchenCan
attr_reader :k_can
def initialize
@k_can = ["garbage"]
end
end
class GarageCan
attr_reader :g_can
def initialize
@g_can = Array.new
end
end
class TakeOut
attr_reader :trash
def initialize
@k = KitchenCan.new
@g = GarageCan.new
end
def remove_trash
@trash = @k.k_can.pop
end
def place_trash
@g.g_can.push(@trash)
end
end
describe KitchenCan do
it 'should have garbage in the can' do
kitchen = KitchenCan.new
kitchen.k_can.length.should_not eq(0)
end
end
describe GarageCan do
it 'should not have garbage in the can at the start' do
garage = GarageCan.new
garage.g_can.length.should eq(0)
end
end
describe TakeOut do
it 'should take garbage out of kitchen can' do
takeout = TakeOut.new
takeout.remove_trash.should eq("garbage")
end
it 'should put garbage into the garage can' do
takeout = TakeOut.new
takeout.place_trash.should eq("garbage")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment