Skip to content

sJhonny-e/RubyPromotionsApp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RubyPromotionsApp

My very first experiment with Ruby and with TDD

A very simple checkout program developed in TDD using RSpec.
You can define different Products and different Promotions;
##Usage Initialize your Checkout object with the Promotions you've created, and start scanning different Products.
When you call the total method, the total price to pay will be calcualted based on the products scanned, and the active promotions you've defined.

##A little about Currently 2 types of promotions are implemented -

  • QuantityDiscountPromotion awards a certain discount % for all occurances of a given product if it's present more than 2 times.
    (i.e 'If you buy 2 or more t-shirts, you get each at a 30% discount')
  • TotalPriceDiscountPromotion awards a certain discount % if the total sum of purchase is larger than a defined threshold.
    (i.e '20% off your order total if you spend more than 100$')

Since promotions affect the total price using a simple Visitor pattern, it's very easy to add or remove promotions with whatever custom logic you'd like.

If you want to dive a bit deeper, I suggest taking a look at the spec folder to see how this thing works :)

About

My very first experiment with Ruby and with TDD

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages