This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is a Ruby implementation of a vending machine kata. The project models a vending machine that can:
- Accept product selection and money insertion
- Return correct products and change
- Track inventory and change denominations
- Handle reloading of products and change
- Please avoid redundant specs when writing new specs
The system is built around three main classes:
VendingMachine: Main orchestrator that manages items and balanceItem: Represents products with name and priceChange: Handles monetary denominations (1p, 2p, 5p, 10p, 20p, 50p, €1, €2)
All classes are in lib/ directory and follow Ruby conventions with corresponding specs in spec/lib/.
# Run all tests
bundle exec rspec
# Run specific test file
bundle exec rspec spec/lib/vending_machine_spec.rb
# Run with specific format
bundle exec rspec --format documentation# Run RuboCop linter
bundle exec rubocop
# Run RuboCop with auto-correct
bundle exec rubocop -a
# Additional quality tools available:
bundle exec reek # Code smell detection
bundle exec flog # Complexity analysis
bundle exec fasterer # Performance suggestions
bundle exec rubycritic # Overall code quality report# Install dependencies
bundle install
# Update dependencies
bundle update- Core logic in
lib/with classes: VendingMachine, Item, Change - Specs in
spec/lib/mirroring the lib structure - RSpec configured to auto-load all lib files via
spec_helper.rb - Ruby 3.4.4 with comprehensive linting and code quality tools