Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Takeaway Challenge
David Campbell - Takeaway Challenge - Weekend 2
==================
```
_________
Expand Down Expand Up @@ -30,10 +30,15 @@ Task
* Write a Takeaway program with the following user stories:

```

user story modelling - https://docs.google.com/document/d/1r0EHAC_h9FZ6FXlEyc3kKvhB3UhVAegkIu0y0tP7TdY/edit

# User Story 1:
As a customer
So that I can check if I want to order something
I would like to see a list of dishes with prices


As a customer
So that I can order the meal I want
I would like to be able to select some number of several available dishes
Expand Down
23 changes: 23 additions & 0 deletions lib/menu.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
class Menu

attr_accessor :dishes, :menu

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this could maybe be attr_reader? instead of accessor.
Should :menu be :menu_items?

def initialize
@dishes = dishes
end

def dishes
dishes = [
{name: 'Chicken Tikka Masala', price: 6.50},
{name: 'Pilau Rice', price: 2.50},
{name: 'Nan Bread', price: 1.95},
]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

end

def menu_items
@menu_items = []
end

def list_of_dishes
dishes.map{ |item, price| menu_items <<item[:name]}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good :)

end
end
13 changes: 13 additions & 0 deletions lib/takeaway.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
require_relative 'menu'

class Takeaway
attr_reader :menu

def initialize(menu:)
@menu = menu
end

def display_menu
menu.list_of_dishes
end
end
1 change: 1 addition & 0 deletions spec/menu_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

14 changes: 14 additions & 0 deletions spec/takeaway_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
require_relative '../lib/takeaway'

describe Takeaway do
subject(:takeaway) { described_class.new(menu: menu) }

let(:menu) { double(:menu, display: display_menu) }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

let(:menu) { Menu.new }

context 'Menu' do
it 'displays a list of dishes' do
expect(menu.menu_items).to include['Chicken Tikka Masala']

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe could've added some more dishes also

end
end
end