Skip to content

Commit

Permalink
Define order and basket classes
Browse files Browse the repository at this point in the history
  • Loading branch information
SelenaSmall committed Sep 2, 2017
1 parent 828dc25 commit 925b83c
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/basket.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Basket class
class Basket
attr_reader :current_order

def initialize
@current_order = nil
end
end
9 changes: 9 additions & 0 deletions lib/order.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Order class
class Order
attr_reader :items, :basket

def initialize(basket)
@items = []
@basket = basket
end
end
13 changes: 13 additions & 0 deletions spec/basket_spec.rb
Original file line number Diff line number Diff line change
@@ -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
20 changes: 20 additions & 0 deletions spec/order_spec.rb
Original file line number Diff line number Diff line change
@@ -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.