Initial setup of a #Ruby project that uses RSpec for TDDing & guard to automatically run the unit tests when the file system changes.
I created this, while working on J. B. Rainsberger's (@jbrains) "The World's Best Intro to TDD" online course ➙ https://online-training.jbrains.ca/p/wbitdd-01
Inside the directory of this repository, run
```bash
ruby bin/new_tdd_project.rb <new_project_name>
```
- Checks that one argument is passed in: the name of a folder to create the new project in
- Checks that this folder does not yet exist (and exits with an error message otherwise)
- Create the new folder (and possibly sub folders) as a sibling of the tdd-setup project (this one)
- Copies the following files & folders to he newly created one:
lib
spec
Gemfile
Guardfile
Rakefile
- Lists the newly created files & folders
- Sets put a new git repo (running
git init
in the new folder) - Runs
bundle install
in that folder
-
Go into the newly created project directory
-
Probably run
bundle exec rake
to see that
RSpec
can be run viaRake
You should get output similar to this:> bundle exec rake # Out put informing about the version manager, RSpec, and Ruby versions used Replace with real expectation actually test something useful Finished in 0.00205 seconds (files took 0.09764 seconds to load) 1 example, 0 failures
-
Running
rspec
withoutrake
should also work fine:bundle exec rspec
-
At least on macOS, using
Guard
should also work:bundle exec guard > bundle exec guard 13:05:36 - INFO - Guard::RSpec is running 13:05:36 - INFO - Running all specs Replace with real expectation actually test something useful Finished in 0.0017 seconds (files took 0.09278 seconds to load) 1 example, 0 failures
In addition to the output on the command line you should also get a notification on the screen, that looks like this: