Skip to content
Vanilla Ruby Command Line Project
Ruby
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
bin
lib
spec
.gitignore
Gemfile
Gemfile.lock
license.md
readme.md

readme.md

Vanilla Ruby Command Line Project

This repository shows a basic setup for a command line application in Ruby.

Getting Started

Ruby and Bundler is expected to be installed on our system.

Installing

After cloning this repository, change into the newly created directory and run

bundle install

This will install all dependencies needed for the project.

Running the Tests

All tests can be run by executing

bundle exec rspec

rspec will automatically find all tests inside the spec directory and run them.

Testing Approach

The test for class Example is only verifying the return value of one method.

Main on the other hand is tested via a test-double that gets injected. This allows us to spy on the output of it. We want to avoid printing anything to the screen while running the tests. Injecting a test double in this instance is a nice way to isolate our application from the command line.

In the executable bin/example we inject $stdout, which is Ruby's variable for its standard output.

Running the Application

To run the application execute bin/example. You should see the text “Ruby Example” being printed.

$: ./bin/example
Ruby Example

Built With

License

This project is licensed under the MIT License - see the license.md file for details.

You can’t perform that action at this time.