Implement CLI usage feature

This commit is contained in:
Thibault Jouan
2013-07-26 20:12:55 +00:00
parent 46f992fdb2
commit a6cfd4d7cb
5 changed files with 76 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
require 'spec_helper'
module Producer::Core
describe CLI do
let(:arguments) { %w{host recipe.rb} }
subject(:cli) { CLI.new(arguments) }
describe '#initialize' do
it 'assigns the arguments' do
expect(cli.arguments).to eq arguments
end
end
describe '#run!' do
context 'missing argument' do
let(:arguments) { %w{host} }
let(:stdout) { StringIO.new }
subject(:cli) { CLI.new(arguments, stdout) }
it 'exits' do
expect { cli.run! }.to raise_error SystemExit
end
it 'prints the usage' do
begin
cli.run!
rescue SystemExit
end
expect(stdout.string).to match /\AUsage: .+/
end
end
end
end
end