In this project you will implement a class with some methods, but you will do it by doing test-driven development (TDD). Remember that the idea is to write tests first and then the code. #Project requirements
- Create a class called Solver. Create a method called factorial that takes one argument, an integer N, and returns the factorial for that number. The factorial is the multiplication of all integers from 1 to N and has the special case that the factorial of 0 is 1. This method only accepts 0 and positive integers, so if a negative integer is given it should raise an exception. Create a method called reverse that takes one argument, a string word, and returns word reversed (e.g. if word is "hello" it returns "olleh").
- Create a method called fizzbuzz that takes one argument, an integer N, and returns a string. The returned string is constructed following these rules: When N is divisible by 3, return "fizz". When N is divisible by 5, return "buzz". When N is divisible by 3 and 5, return "fizzbuzz". Any other case, return N as a string (e.g. say N is 7 then return "7"). Remember to start with tests for all of the methods described above. Your commit history should prove that you have used TDD.
Client
- serves as good practice for TDD.
- Reverse a string app.
- FizzBuzz app
To get a local copy up and running, follow these steps.
In order to run this project you need:
- Mac or PC
- Install Ruby
- Understanding of Ruby
- IRB
- Gems to test linters
- RSpec to run tests
Clone this repository to your desired folder:
cd into your-folder
git clone https://github.com/admirerbrown/Rspec_TDD.git
Install this project with:
- GitHub Actions
- Linters
- Rubocop
- Ruby
- Rspec
- Use this project as a step to learning to practice building backend applications with Ruby and OOP concepts.
-
run "Rspec your-file-name"
👤 Samuel Kyere
- GitHub: @admirerbrown
- Twitter: @admirerbrown
- LinkedIn: @samuelkyere
- **Add more practice classes **
- Add more complex requirements
- Add console interface
Contributions, issues, and feature requests are welcome!
Feel free to check the issues page.
If you like this project, please leave a ⭐️
I would like to thank Microverse for providing us with reading materials that aided us to during the project development
-
Can I use this code?
- yes, it is open source. Feel free to fork it.
-
Can I contribute to this project?
- Contact me so I can add you as a collaborator. Alternatively you can leave an issue, it will be well appreciated.
This project is MIT licensed.