-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
828dc25
commit 925b83c
Showing
4 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |