From 53d9ae7fc69a2083a11f798b924738220614fbb0 Mon Sep 17 00:00:00 2001 From: George Dainton Date: Mon, 2 May 2022 23:21:03 +0100 Subject: [PATCH 1/2] Menu class initialized with dishes hash --- lib/menu.rb | 14 ++++++++++++++ lib/takeaway.rb | 0 myREADME.md | 35 +++++++++++++++++++++++++++++++++++ spec/menu_spec.rb | 7 +++++++ spec/takeaway_spec.rb | 0 5 files changed, 56 insertions(+) create mode 100644 lib/menu.rb create mode 100644 lib/takeaway.rb create mode 100644 myREADME.md create mode 100644 spec/menu_spec.rb create mode 100644 spec/takeaway_spec.rb diff --git a/lib/menu.rb b/lib/menu.rb new file mode 100644 index 0000000000..17a64530f6 --- /dev/null +++ b/lib/menu.rb @@ -0,0 +1,14 @@ +class Menu +attr_reader :dishes + + def initialize + @dishes = [ + {name: 'Cacio e pepe', price: 10}, + {name: 'Alla Gricia', price: 11.50}, + {name: 'Carbonara', price: 12}, + {name: 'Amaracitiana', price: 11} + + ] + end + +end \ No newline at end of file diff --git a/lib/takeaway.rb b/lib/takeaway.rb new file mode 100644 index 0000000000..e69de29bb2 diff --git a/myREADME.md b/myREADME.md new file mode 100644 index 0000000000..26cb53d79c --- /dev/null +++ b/myREADME.md @@ -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 diff --git a/spec/menu_spec.rb b/spec/menu_spec.rb new file mode 100644 index 0000000000..2eb0a99a12 --- /dev/null +++ b/spec/menu_spec.rb @@ -0,0 +1,7 @@ +require 'menu' + +describe Menu do + it 'can display list of available items' do + expect(subject.dishes).to include({name: 'Cacio e pepe', price: 10}) + end +end \ No newline at end of file diff --git a/spec/takeaway_spec.rb b/spec/takeaway_spec.rb new file mode 100644 index 0000000000..e69de29bb2 From 2169c049f07c647db5d33c7dab55d950f742983d Mon Sep 17 00:00:00 2001 From: George Dainton Date: Tue, 3 May 2022 09:57:20 +0100 Subject: [PATCH 2/2] Choose item method --- lib/menu.rb | 9 +++++---- lib/order.rb | 11 +++++++++++ lib/takeaway.rb | 0 spec/menu_spec.rb | 2 +- spec/order_spec.rb | 14 ++++++++++++++ spec/takeaway_spec.rb | 0 6 files changed, 31 insertions(+), 5 deletions(-) create mode 100644 lib/order.rb delete mode 100644 lib/takeaway.rb create mode 100644 spec/order_spec.rb delete mode 100644 spec/takeaway_spec.rb diff --git a/lib/menu.rb b/lib/menu.rb index 17a64530f6..20e9cec658 100644 --- a/lib/menu.rb +++ b/lib/menu.rb @@ -3,12 +3,13 @@ class Menu def initialize @dishes = [ - {name: 'Cacio e pepe', price: 10}, - {name: 'Alla Gricia', price: 11.50}, - {name: 'Carbonara', price: 12}, - {name: 'Amaracitiana', price: 11} + {pomodoro: 10}, + {vongole: 13.50}, + {carbonara: 12}, + {amaracitiana: 11} ] + end end \ No newline at end of file diff --git a/lib/order.rb b/lib/order.rb new file mode 100644 index 0000000000..58b3c8fcb8 --- /dev/null +++ b/lib/order.rb @@ -0,0 +1,11 @@ +class Order + + def initialize(menu = Menu.new) + @menu = menu + end + + def choose_item(item) + end + + +end \ No newline at end of file diff --git a/lib/takeaway.rb b/lib/takeaway.rb deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/spec/menu_spec.rb b/spec/menu_spec.rb index 2eb0a99a12..e7367322e1 100644 --- a/spec/menu_spec.rb +++ b/spec/menu_spec.rb @@ -2,6 +2,6 @@ describe Menu do it 'can display list of available items' do - expect(subject.dishes).to include({name: 'Cacio e pepe', price: 10}) + expect(subject.dishes).to include({pomodoro: 10}) end end \ No newline at end of file diff --git a/spec/order_spec.rb b/spec/order_spec.rb new file mode 100644 index 0000000000..5e637d6f2d --- /dev/null +++ b/spec/order_spec.rb @@ -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 diff --git a/spec/takeaway_spec.rb b/spec/takeaway_spec.rb deleted file mode 100644 index e69de29bb2..0000000000