From a2d5aef47ce6ec5a2ba287a4a04371a923f45514 Mon Sep 17 00:00:00 2001 From: Ruzeka Uddin Date: Sun, 3 Apr 2022 14:08:18 +0100 Subject: [PATCH 1/5] Added Readme --- README.md | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index dbcb154e43..89985b8a9c 100644 --- a/README.md +++ b/README.md @@ -14,21 +14,19 @@ Takeaway Challenge ``` -Instructions +## Task ------- +To write a Takeaway programme which will include a menu that lists dishes & prices of each dish. Customers will be able to use the programme to place an order & select several dishes they want with quantities, the programme will be able to calculate the total cost of the order as well. +I will be using Twilio in order to send text messages to customers to inform them when their order will be delivered. Within the testing process, I will try to use stubs and doubles in order to isolate my tests. -* Feel free to use google, your notes, books, etc. but work on your own -* If you refer to the solution of another coach or student, please put a link to that in your README -* If you have a partial solution, **still check in a partial solution** -* You must submit a pull request to this repo with your code by 9am Monday morning - -Task ------ - -* Fork this repo -* Run the command 'bundle' in the project directory to ensure you have all the gems -* Write a Takeaway program with the following user stories: +## Instructions +---------------- +Instructions +Clone this repository to your desired location, +Run the command 'bundle' in the project directory to ensure you have all the gems. +Run RSpec in the `takeaway_challenge` directory in order to run the unit tests. +## User Story ``` As a customer So that I can check if I want to order something @@ -47,6 +45,17 @@ 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 ``` +## Domain Model Table +------------------------------------ +| Objects | Messages | +| -------------- | ------------- | +| Menu/dishes | list of dishes | +| Prices | list prices of dishes| +| Order | place an order | +| Text | receive texts | +----------------------------------- + + * Hints on functionality to implement: * 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". From 3e2b1b75ba49c92d7472d3eb0d40052ea0d8c670 Mon Sep 17 00:00:00 2001 From: Ruzeka Uddin Date: Sun, 3 Apr 2022 14:15:03 +0100 Subject: [PATCH 2/5] added inital passed test --- lib/menu.rb | 4 ++++ spec/menu_spec.rb | 8 ++++++++ 2 files changed, 12 insertions(+) create mode 100644 lib/menu.rb create mode 100644 spec/menu_spec.rb diff --git a/lib/menu.rb b/lib/menu.rb new file mode 100644 index 0000000000..a27633fe71 --- /dev/null +++ b/lib/menu.rb @@ -0,0 +1,4 @@ +class Menu + + +end \ No newline at end of file diff --git a/spec/menu_spec.rb b/spec/menu_spec.rb new file mode 100644 index 0000000000..82a9841914 --- /dev/null +++ b/spec/menu_spec.rb @@ -0,0 +1,8 @@ +require "menu" + +describe Menu do + it' shows a list of dishes with prices' do + + end +end + From a721c9329301882176c58905017fa6b259e94339 Mon Sep 17 00:00:00 2001 From: Ruzeka Uddin Date: Sun, 3 Apr 2022 23:40:48 +0100 Subject: [PATCH 3/5] created a menu which lists dishes & prices --- lib/menu.rb | 19 ++++++++++++++++++- spec/menu_spec.rb | 14 +++++++++++--- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/lib/menu.rb b/lib/menu.rb index a27633fe71..07c12a316b 100644 --- a/lib/menu.rb +++ b/lib/menu.rb @@ -1,4 +1,21 @@ class Menu - + attr_reader :lists_dishes + def initialize + @list_hash = {} + end + + def lists_dishes + @List_hash = + { "Cod" => 11.0, + "Rock" => 13.0, + "Haddock" => 13.0, + "Plaice" => 13.0, + "Skate" => 18.0, + "Code Roe" => 3.60, + "Fish Cake" => 3.0, + "Chips" => 3.80, + "chip Roll" => 4.50, + } + end end \ No newline at end of file diff --git a/spec/menu_spec.rb b/spec/menu_spec.rb index 82a9841914..a7e9625429 100644 --- a/spec/menu_spec.rb +++ b/spec/menu_spec.rb @@ -1,8 +1,16 @@ -require "menu" +require_relative '../lib/menu' describe Menu do - it' shows a list of dishes with prices' do + + describe "#lists_dishes" do + + it' shows a list of all dishes with prices' do + menu = Menu.new + expect(subject).to respond_to(:lists_dishes) end -end + end +end + + From ed594398fe07a5b3e43df745fa68aeec81785ac1 Mon Sep 17 00:00:00 2001 From: Ruzeka Uddin Date: Mon, 4 Apr 2022 08:56:45 +0100 Subject: [PATCH 4/5] added user story 3 final testing stage --- lib/menu.rb | 9 +++++++++ lib/order.rb | 20 ++++++++++++++++++++ spec/menu_spec.rb | 18 ++++++++++++------ spec/order_spec.rb | 22 ++++++++++++++++++++++ 4 files changed, 63 insertions(+), 6 deletions(-) create mode 100644 lib/order.rb create mode 100644 spec/order_spec.rb diff --git a/lib/menu.rb b/lib/menu.rb index 07c12a316b..1a44946d9f 100644 --- a/lib/menu.rb +++ b/lib/menu.rb @@ -18,4 +18,13 @@ def lists_dishes "chip Roll" => 4.50, } end + + def view_dishes + @list_hash.each { |item, price| puts "#{item} £#{price}" } + end + + def check_availability(item) + message = "Dish not available. Please make a new selection." + raise message if @list_hash[item].nil? + end end \ No newline at end of file diff --git a/lib/order.rb b/lib/order.rb new file mode 100644 index 0000000000..3db35ea407 --- /dev/null +++ b/lib/order.rb @@ -0,0 +1,20 @@ +require 'menu' +attr_accessor :total, :lists_dishes + +class Order + + def initialize(total, lists_dishes) + @total = 0 + @lists_dishes = [] + end + + def add(dish) + @lists_dishes << "#{dish.name} = £#{dish.price}" + @total += dish.price + end + + def add(dish) + @lists_dishes << "#{dish.name} = £#{dish.price}" + @total += dish.price + end +end \ No newline at end of file diff --git a/spec/menu_spec.rb b/spec/menu_spec.rb index a7e9625429..5a8eb3347e 100644 --- a/spec/menu_spec.rb +++ b/spec/menu_spec.rb @@ -3,13 +3,19 @@ describe Menu do describe "#lists_dishes" do - - it' shows a list of all dishes with prices' do - menu = Menu.new - expect(subject).to respond_to(:lists_dishes) - - end + menu = Menu.new + it' shows a list of all dishes with prices' do + expect(subject).to respond_to(:lists_dishes) + end end + + describe '#check_availability' do + menu = Menu.new + it 'raises an error when item is not available' do + expect { subject.check_availability('Fish Cake') }.to raise_error 'Dish not available. Please make a new selection.' + end + end + end diff --git a/spec/order_spec.rb b/spec/order_spec.rb new file mode 100644 index 0000000000..9677f4f8a6 --- /dev/null +++ b/spec/order_spec.rb @@ -0,0 +1,22 @@ +require_relative '../lib/order' + +describe Order do +let(:dish) { double :dish, :name => "Cod", :price => 11.0 } + it 'has a default total of 0' do + expect(subject.total).to eq 0 + end + + it 'should create an order of dishes from menu' do + expect(subject.order).to eq [] + end + + it 'can add items to the order' do + subject.add(dish) + expect(subject.items).to include("Cod = £11") + end + + it 'updates the total with each added item' do + subject.add(dish) + expect(subject.total).to eq (5) + end +end \ No newline at end of file From eb3854c56e7b5232ebfc1607fa01f2539551d237 Mon Sep 17 00:00:00 2001 From: Ruzeka Uddin Date: Mon, 4 Apr 2022 09:04:18 +0100 Subject: [PATCH 5/5] pull request template --- .github/pull_request_template.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 5309762cb2..67c505715e 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,4 +1,4 @@ -# Your name +# Ruzeka Uddin Please write your full name here to make it easier to find your pull request. @@ -6,9 +6,10 @@ Please write your full name here to make it easier to find your pull request. Please list which user stories you've implemented (delete the ones that don't apply). -- [ ] User story 1: "I would like to see a list of dishes with prices" -- [ ] User story 2: "I would like to be able to select some number of several available dishes" -- [ ] User story 3: "I would like to check that the total I have been given matches the sum of the various dishes in my order" +- [ * ] User story 1: "I would like to see a list of dishes with prices" +- [ *] User story 2: "I would like to be able to select some number of several available dishes" +- [ *] User story 3: "I would like to check that the total I have been given matches the sum of the various dishes in my order" +incompleted final testing stage - [ ] User story 4: "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" # README checklist