https://github.com/nodeg/ruby-testing
Basic tests in Ruby for understanding TDD and BDD
https://github.com/nodeg/ruby-testing
bdd github-actions ruby tdd testing
Last synced: about 2 months ago
JSON representation
Basic tests in Ruby for understanding TDD and BDD
- Host: GitHub
- URL: https://github.com/nodeg/ruby-testing
- Owner: nodeg
- License: mit
- Created: 2023-09-06T11:29:34.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-11-04T10:02:42.000Z (6 months ago)
- Last Synced: 2025-03-17T14:04:18.110Z (2 months ago)
- Topics: bdd, github-actions, ruby, tdd, testing
- Language: Ruby
- Homepage:
- Size: 20.5 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/nodeg/ruby-testing/actions/workflows/tests.yml)
[](https://github.com/nodeg/ruby-testing/actions/workflows/rubocop.yml)# Testing using Ruby and Cucumber
These are some very basic examples on how TDD and BDD work in Ruby.
## Test-driven development (TDD)
### General principles
1. Write the smallest possible test case (unit test) for one unit in the code.
1. Run the test and watch it failing.
1. Write the actual code for this unit.
1. Run the test again.
1. Repeat this as long as the test passes and refactor the code in the process.### Executing the test
* Go inside the `tdd` folder
* Execute the test with```bash
ruby tests/hello_test.rb
```The test explicitly does not fail because of the CI tests.
## Behavior-driven development (BDD)
The idea behind BDD is built on top of TDD, with the difference of writing tests as a
specification of the behavior of a system instead of just testing the code.### Initialize Cucumber
Before you start with Cucumber, you need to initializes the folder structure and
generate conventional files. This was already done here and you only need it when
you start a fresh project.### Executing the BDD tests
* Go inside the `bdd` folder
* Execute the test with```bash
# execute all tests
cucumber# execute one specific test
cucumber features/calculator.feature
cucumber features/hello.feature
```