Introduction to TDD and RSpec
Introduction to TDD and RSpec
Welcome to your second lesson in this course dedicated to practicing Test Driven Development (TDD) utilizing Ruby and RSpec. In this unit, we will continue adding features to our calculate_discount function. We have five more requirements for you to implement!
In this course, the emphasis is placed on hands-on practice, where you'll receive requirements through tests, one at a time. Your objective is to implement code that makes each test pass, simulating a real-world TDD environment. As the course guide, it's akin to being your pair programmer, providing test-driven prompts to hone your skills as you progress.
Understanding the Red-Green-Refactor Cycle
As a reminder, the Red-Green-Refactor cycle is central to TDD, guiding your development process:
- Red: Start by writing a failing test to define the next step.
- Green: Implement just enough code to pass the test, focusing on functionality.
- Refactor: Optimize the code for clarity and efficiency without changing its behavior.
More Requirements for `calculate_discount` Function
In this section, you will enhance the calculate_discount function by implementing five additional requirements:
-
Non-Numeric Price Input Handling: Learn how to validate inputs and handle errors for non-numeric price values.
-
Non-Numeric Discount Input Handling: Understand how to ensure discount inputs are numeric and manage invalid cases effectively.
-
Handling Very Small Prices: Discover techniques to manage very small prices and ensure they adhere to a defined minimum value post-discount.
-
Minimum Discount Percentage Application: Implement logic to apply a minimum discount percentage when provided with a lower percentage.
-
Capping Maximum Discount Amount: Explore methods for capping the discount at a maximum dollar value, ensuring the discount does not exceed this cap.
Below is the calculate_discount function that you will enhance by implementing five additional requirements:
7. Non-Numeric Price Input Handling
