Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Takeaway Challenge (partial) #2240

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
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
15 changes: 15 additions & 0 deletions lib/menu.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class Menu
attr_reader :dishes

def initialize
@dishes = [
{pomodoro: 10},
{vongole: 13.50},
{carbonara: 12},
{amaracitiana: 11}

]

end

end
11 changes: 11 additions & 0 deletions lib/order.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class Order

def initialize(menu = Menu.new)
Copy link

Choose a reason for hiding this comment

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

(menu = Menu.new) may not need to be there, on the next line you could have @menu = Menu.new

@menu = menu
end

def choose_item(item)
end


end
35 changes: 35 additions & 0 deletions myREADME.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
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

As a customer
So that I can verify that my order is correct
I would like to check that the total I have been given matches the sum of the various dishes in my order

As a customer
So that I am reassured that my order will be delivered on time
I would like to receive a text such as "Thank you! Your order was placed and will be delivered before 18:52" after I have ordered

Ensure you have a list of dishes with prices
- The text should state that the order was placed successfully and that it will be delivered 1 hour from now, e.g. "Thank you! Your order was placed and will be delivered before 18:52".
- The text sending functionality should be implemented using Twilio API. You'll need to register for it. It’s free.
- Use the twilio-ruby gem to access the API
- Use the Gemfile to manage your gems
- Make sure that your Takeaway is thoroughly tested and that you use mocks and/or stubs, as necessary to not to send texts when your tests are run
- However, if your Takeaway is loaded into IRB and the order is placed, the text should actually be sent
- Note that you can only send texts in the same country as you have your account. I.e. if you have a UK account you can only send to UK numbers.

Plan
- Get twilio API
- Identify classes
- Write tests for each class and get them green
- Refactor

Classes
- Menu
- Order
- Text
7 changes: 7 additions & 0 deletions spec/menu_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require 'menu'

describe Menu do
it 'can display list of available items' do
expect(subject.dishes).to include({pomodoro: 10})
end
end
14 changes: 14 additions & 0 deletions spec/order_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
require 'order'

describe Order do

it 'can respond to choose items' do
expect(subject).to respond_to(:choose_item)
end

it 'can choose items from the menu' do
expect(subject.choose_item(item,quantity)).to eq[{carbonara: 19}]
end


end