Aruba and ArubaDoubles are tools for testing command-line programs using Cucumber. They allow for setting up command stubs, then testing expectations on those stubs. This gem helps to integrate the two directly in RSpec.
Add this line to your application's Gemfile:
group :test do
gem 'aruba-rspec'
endAdd aruba-rspec to your spec_helper.rb file as follows:
require 'aruba/rspec'
RSpec.configure do |config|
config.include ArubaDoubles
config.before :each do
Aruba::RSpec.setup
end
config.after :each do
Aruba::RSpec.teardown
end
endNote that ArubaDoubles needs to be included into your RSpec configuration. This allows command doubles to be used.
This comes out of ArubaDoubles:
describe 'Using doubles' do
before do
double_cmd('which', puts: '/some/path')
double_cmd('sudo', warn: 'No!', exit: 1)
end
it 'can run a command that succeeds' do
expect(`which thing`).to eq('/some/path')
expect($?.exitstatus).to eq(0)
end
it 'can run a command that fails' do
expect(`sudo do soemthing`).to be nil
expect($?.exitstatus).to eq(1)
end
enddescribe MyThing do
it 'calls out to an external command' do
double_cmd('thing')
expect {
`thing --with --options`
}.to shellout('thing --with --options')
end
endit 'exits 50' do
double_cmd('thing', exit: 50)
expect {
`thing 1 2 3`
}.to have_exit_status(50)https://github.com/cucumber/arubahttps://github.com/bjoernalbers/aruba-doubles
- Fork it ( http://github.com//aruba-rspec/fork )
- Use feature branches
- Write tests for any changes