1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222
|
[](https://github.com/cucumber/aruba/stargazers)
[](https://raw.githubusercontent.com/cucumber/aruba/main/LICENSE)
[](http://badge.fury.io/rb/aruba)
[](https://codeclimate.com/github/cucumber/aruba)
[](https://cucumber.io/support)
**This is the [latest](https://github.com/cucumber/aruba/blob/main/features/README.md)
version of our README.md ([main](https://github.com/cucumber/aruba/tree/main) branch).**
Aruba is an extension for popular TDD and BDD frameworks like Cucumber, RSpec
and Minitest to make testing of command line applications meaningful, easy and
fun.
Your benefits:
* Test any command line application implemented in any programming language –
e.g. Bash, Python, Ruby, Java, ...
* Manipulate the file system and the process environment with helpers working
similarly to tools you may know from your shell
* No worries about leaking state: The file system and the process environment
will be reset between tests
* Support by a helpful and welcoming community – see our
[Code of Conduct](https://github.com/cucumber/cucumber/blob/main/CODE_OF_CONDUCT.md)
* The [documentation](https://app.cucumber.pro/projects/aruba) is our contract
with you. You can expect Aruba to work as documented
Our Vision:
* Help our users to build better command line applications written in any
programming language
* Make creating documentation for command line applications simple and fun
* Support the cucumber community in its effort to create a specification for
all official cucumber implementations
Our Focus:
* Test the user-interaction with the commands at runtime – this excludes
the process of installation/deployment of commands like installing Rubygems
with `gem install <your-gem>`.
# Install
Add this line to your application's `Gemfile`:
```ruby
gem 'aruba'
```
And then execute:
```bash
bundle
```
Or install it yourself as:
```bash
gem install aruba
```
# Usage
**Note:** Please also see this
[feature test](01_getting_started_with_aruba/supported_testing_frameworks.feature)
for the most up to date documentation.
## Getting started
1. Clone the "Getting Started" application and make the cloned repository your current working directory
```bash
git clone https://github.com/cucumber/aruba-getting-started.git
cd aruba-getting-started
```
2. Install the required dependencies
```bash
bundle install
```
### Cucumber
1. Create a file named `features/support/env.rb` with:
```ruby
require 'aruba/cucumber'
```
2. Create a file named `features/use_aruba_with_cucumber.feature` with:
```ruby
Feature: Cucumber
Scenario: First Run
Given a file named "file.txt" with:
"""
Hello, Aruba!
"""
When I run `aruba-test-cli file.txt`
Then the file "file.txt" should contain:
"""
Hello, Aruba!
"""
```
3. Run `cucumber`
```bash
bundle exec cucumber
```
### RSpec
1. Add the following line to the `spec/spec_helper.rb` file.
```ruby
require 'aruba/rspec'
```
2. Create a file named `spec/use_aruba_with_rspec_spec.rb` with:
```ruby
require 'spec_helper'
RSpec.describe 'First Run', :type => :aruba do
let(:file) { 'file.txt' }
let(:content) { 'Hello, Aruba!' }
before { write_file file, content }
before { run_command('aruba-test-cli file.txt') }
# Full string
it { expect(last_command_started).to have_output content }
# Substring
it { expect(last_command_started).to have_output(/Hello/) }
end
```
3. Run `rspec`
```bash
bundle exec rspec
```
### Minitest
1. Add the following line to the `test/test_helper.rb` file.
```ruby
require 'aruba/api'
```
3. Add a file named `test/use_aruba_with_minitest.rb` with:
```ruby
require 'test_helper'
require 'minitest/autorun'
class FirstRun < Minitest::Test
include Aruba::Api
def setup
setup_aruba
end
def test_getting_started_with_aruba
file = 'file.txt'
content = 'Hello, Aruba!'
write_file file, content
run_command_and_stop 'aruba-test-cli file.txt'
assert_equal last_command_started.output.chomp, content
end
end
```
4. Run your tests
```bash
bundle exec ruby -I lib:test test/use_aruba_with_minitest.rb
```
## Development
### Api Documentation
A full documentation of the API can be found
[here](http://www.rubydoc.info/github/cucumber/aruba/main/frames).
### Code branches
Development for the upcoming 1.0.0 release takes place in the `main` branch.
Maintenance of the current 0.14.x releases takes place in the `0-14-stable`
branch. After the 1.0.0 release, development will take place in the `main`
branch as much as possible. Stable branches will not be created until
absolutely necessary.
# Initialize an existing project
There's an initializer to make it easier for you to get started.
1. Go to your project's directory
2. Make sure it's under version control and all changes are committed to your
version control repository
3. Run one of the following commands depending on the tools you use to test your project.
This assumes, that you use either `rspec`, `cucumber-ruby` or `minitest` to
write the tests for your project. Besides that, your tool can be implemented
in any programming language you like.
```bash
aruba init --test-framework rspec
aruba init --test-framework cucumber
aruba init --test-framework minitest
```
# Copyright
Copyright (c) 2010-2020 Aslak Hellesøy et al. See [MIT License](LICENSE) for details.
|