Skip to content

rosieallott/takeaway-challenge

 
 

Repository files navigation

Takeaway Challenge

                            _________
              r==           |       |
           _  //            |  M.A. |   ))))
          |_)//(''''':      |       |
            //  \_____:_____.-------D     )))))
           //   | ===  |   /        \
       .:'//.   \ \=|   \ /  .:'':./    )))))
      :' // ':   \ \ ''..'--:'-.. ':
      '. '' .'    \:.....:--'.-'' .'
       ':..:'                ':..:'

Instructions

  • Challenge time: rest of the day and weekend, until Monday 9am
  • 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:
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
  • Hints on functionality to implement:

    • Ensure you have a list of dishes with prices
    • Place the order by giving the list of dishes, their quantities and a number that should be the exact total. If the sum is not correct the method should raise an error, otherwise the customer is sent a text saying 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.
  • Advanced! (have a go if you're feeling adventurous):

    • Implement the ability to place orders via text message.
  • A free account on Twilio will only allow you to send texts to "verified" numbers. Use your mobile phone number, don't worry about the customer's mobile phone.

  • Finally submit a pull request before Monday at 9am with your solution or partial solution. However much or little amount of code you wrote please please please submit a pull request before Monday at 9am

In code review we'll be hoping to see:

  • All tests passing
  • High Test coverage (>95% is good)
  • The code is elegant: every class has a clear responsibility, methods are short etc.

Reviewers will potentially be using this code review rubric. Referring to this rubric in advance will make the challenge somewhat easier. You should be the judge of how much challenge you want this weekend.

Notes on Test Coverage

You can see your test coverage when you submit a pull request, and you can also get a summary locally by running:

$ coveralls report

This repo works with Coveralls to calculate test coverage statistics on each pull request.

Build Badge Example

Build Status Coverage Status

Working through the solution

1: Map out classes (I currently expect) and possible class methods

Objects Messages
Takeaway start_order
checkout
send_confirm
Order select_dish
check_menu
Menu show_list
Verify sum_total
Confirmation send_text

2: Revisit user Stories

##User Stories

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

3: Make Takeaway "parent" class, delegating ordering, verification and confirmation. Order delegates/injects Menu

4: Feature Test functionality

003 > require './lib/order'
 => true
2.3.1 :004 > order = Order.new
 => #<Order:0x007fb1fb0151d0 @basket={}, @menu=#<Menu:0x007fb1fb0151a8 @list={:Margerita=>5, :Napolitan=>7, :Pepperoni=>9}>>
2.3.1 :005 > order.menu.show_list
Pizza options are
Margerita: £5
Napolitan: £7
Pepperoni: £9
 => {:Margerita=>5, :Napolitan=>7, :Pepperoni=>9}
2.3.1 :006 > order.select_dish("Pepperoni",3)
 => 3

About

Use the Twilio Gem to order food

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 100.0%