No description
Find a file
2026-07-23 09:37:22 -05:00
lib Refactor Checkout to apply checkout level promotions 2026-07-23 09:37:22 -05:00
test Update tests for CheckoutPromotion 2026-07-23 09:37:09 -05:00
.ruby-version Lock Ruby version 2026-07-16 20:55:27 -05:00
.tool-versions Lock Ruby version 2026-07-16 20:55:27 -05:00
Gemfile Add Pry for debugging 2026-07-16 19:16:44 -05:00
Gemfile.lock Add Pry for debugging 2026-07-16 19:16:44 -05:00
Rakefile Add README and Rakefile 2026-07-16 18:57:41 -05:00
README.md Add new requirement to readme 2026-07-23 09:35:46 -05:00

Raspberry Pi Technical Test

Setup

  1. Install Ruby 4.0.5 and bundler using your preferred method.

  2. Run:

$ bundle install

Run Tests

$ rake test

Notes

  • I'm storing the prices as an integer number of pennies. This avoids any rounding issues with floats. Other options might be BigDecimal or using the money gem.

  • I've implemented the promotions as an overrideable sum proc on each product. This works well but wouldn't really be practical for a user to administer in any way.

  • The buy_one_get_one_free promotion proc could probably be refactored to be a buy_x_get_one_free method, but this would make the maths more complicated.

  • There is currently no way to remove a product from the checkout. We can implement a #remove method easily enough.

  • There are currently no tests for the Promotions module. I would have added some if I'd had more time.

New Requirements

  • If you buy a Raspberry Pi 5, and a Zero 2W, you get £5 discount