In this project we implemented a class with some methods using test-driven development (TDD). The idea is to write tests first and then the code.
Describe the tech stack and include only the relevant sections that apply to your project.
Language
Linter
Test Library
We created a class called
Solver
with the following methods:
factorial
that takes one argument, an integernum
, and returns the factorial for that number. The factorial is the multiplication of all integers from 1 tonum
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.reverse
that takes one argument, a string word, and returns word reversed (e.g. if word ishello
it returnsolleh
).fizzbuzz
that takes one argument, an integernum
, and returns a string. The returned string is constructed following these rules:- When
num
is divisible by3
, returnfizz
. - When
num
is divisible by5
, returnbuzz
. - When
num
is divisible by3
and5
, returnfizzbuzz
. - Any other case, return
num
as a string (e.g. saynum
is7
then return7
).
- When
In order to run this project you need:
- Install Ruby on your computer (machine)
Clone this repository to your desired folder:
git clone git@github.com:kusiLaw/TDD-project.git
cd TDD-project
Install this project with:
gem install bundler
bundle install
To run the project, execute the following command:
ruby solver.rb
In order to run unit tests on the local machine Rspec gem should be installed
- run in the terminal
gem install rspec
- After installation run
rspec spec/file_name.rb
- If you are interested in running all the tests together then
rspec spec
- For more information please visit RubyGuides.
👤 Kwaleyela Musilizo Ikafa
👤 Praises Tula
Contributions, issues, and feature requests are welcome!
Feel free to check the issues page.
Give a ⭐️ if you like this project!