Skip to content
An exercise that simulates the workflow process of a vending machine.
Ruby
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
experimental
lib
spec
README.md
flowchart.png
main.rb
products.csv

README.md

Vending-Machine

The application tries to simulate the behavior of a vending machine. This is the entire diagram of the workflow that it follows and basically, these are all of the different options we expect to have.

Flow Chart

Usage

Since this application was built using ruby you need to make sure you have it installed. You can follow the instructions here depending on your operative system to install it. It is recommended to use at least ruby version 2.6.3.

To run the application, first, in your terminal run the following command to clone this repo using the next command:

$ git clone https://github.com/alexventuraio/vending-machine

Then access the folder with:

$ cd vending-machine/

Now, run the entry point of the app with the next command:

$ ruby main.rb

At this point you will be able to see the main menu of the application in your terminal. Just follow the instructions on the screen to operate the machine.🎉🎉🎉

It will load the default CSV file products.csv as products catalog which is included in this repository.

Use a different CSV file for Products menu

If you want to provide a different menu file, first make sure that the structure of each row in your file meets the structure below. In the CSV file, each row represents a product to be shown in the products menu.

Name Code Price
Water C1 1.25
Soda C3 2.99

It is important to emphasize that you do not have to include any headers row in the file, just include product rows with the same structure. The final file could be something like this:

Water C1 1.25
Soda C3 2.99
Water,C1,1.25
Soda,C3,2.99

Once you have the file ready, you can execute the entry command but now pass the path to the file as an argument as shown below:

$ ruby main.rb "spec/test_products.csv"

Test suite

First, you need to make sure you have RSpec installed. As mentioned before, once you have ruby installed in your system, installing RSpec is pretty straightforward. Just run the following command inside the root folder of the application:

$ gem install rspec

Once your have RSpec in your system, you just have to execute the following command to run the test suite:

$ bundle exec rspec
You can’t perform that action at this time.