Skip to content
Permalink
Browse files

Define order and basket classes

  • Loading branch information...
SelenaSmall committed Sep 2, 2017
1 parent 828dc25 commit 925b83c8fe0578ec24bc40e2e4e179a30fe842c2
Showing with 50 additions and 0 deletions.
  1. +8 −0 lib/basket.rb
  2. +9 −0 lib/order.rb
  3. +13 −0 spec/basket_spec.rb
  4. +20 −0 spec/order_spec.rb
@@ -0,0 +1,8 @@
# Basket class
class Basket
attr_reader :current_order

def initialize
@current_order = nil
end
end
@@ -0,0 +1,9 @@
# Order class
class Order
attr_reader :items, :basket

def initialize(basket)
@items = []
@basket = basket
end
end
@@ -0,0 +1,13 @@
require 'rspec'
require 'spec_helper'
require './lib/basket'

describe Basket do
describe '#initialize' do
it 'should have a current_order attribute which is a nil' do
instance = Basket.new

expect(instance.current_order).to be_nil
end
end
end
@@ -0,0 +1,20 @@
require 'rspec'
require 'spec_helper'
require './lib/order'

describe Order do
describe '#initialize' do
it 'should have a items attribute which is an empty Array' do
instance = Order.new(Basket.new)

expect(instance.items).to be_a Array
expect(instance.items).to be_empty
end

it 'should have a basket attribute which is an instance of Basket' do
instance = Order.new(Basket.new)

expect(instance.basket).to be_a Basket
end
end
end

0 comments on commit 925b83c

Please sign in to comment.
You can’t perform that action at this time.