2013-07-28 19:03:06 -04:00
|
|
|
# encoding: utf-8
|
|
|
|
|
2012-08-28 12:57:39 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Mutant::CLI, '.run' do
|
|
|
|
subject { object.run(argv) }
|
|
|
|
|
2013-09-08 16:12:23 -04:00
|
|
|
let(:object) { described_class }
|
|
|
|
let(:argv) { double('ARGV') }
|
|
|
|
let(:attributes) { double('Options') }
|
|
|
|
let(:runner) { double('Runner', success?: success) }
|
|
|
|
let(:config) { double('Config') }
|
|
|
|
let(:instance) { double(described_class.name, config: config) }
|
2012-08-28 12:57:39 -04:00
|
|
|
|
2013-04-17 23:31:21 -04:00
|
|
|
before do
|
2013-09-08 16:12:23 -04:00
|
|
|
described_class.stub(new: instance)
|
|
|
|
Mutant::Runner::Config.stub(run: runner)
|
2012-08-28 12:57:39 -04:00
|
|
|
end
|
|
|
|
|
2013-01-21 17:54:25 -05:00
|
|
|
context 'when runner is successful' do
|
|
|
|
let(:success) { true }
|
2012-08-28 12:57:39 -04:00
|
|
|
|
2012-08-28 13:43:15 -04:00
|
|
|
it { should be(0) }
|
|
|
|
|
2012-09-15 18:51:47 -04:00
|
|
|
it 'should run with attributes' do
|
2013-07-28 17:52:05 -04:00
|
|
|
Mutant::Runner::Config
|
|
|
|
.should_receive(:run)
|
|
|
|
.with(config)
|
|
|
|
.and_return(runner)
|
2012-08-28 13:43:15 -04:00
|
|
|
should be(0)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when runner fails' do
|
2013-01-21 17:54:25 -05:00
|
|
|
let(:success) { false }
|
2012-08-28 13:43:15 -04:00
|
|
|
|
|
|
|
it { should be(1) }
|
|
|
|
|
2012-09-15 18:51:47 -04:00
|
|
|
it 'should run with attributes' do
|
2013-07-28 17:52:05 -04:00
|
|
|
Mutant::Runner::Config
|
|
|
|
.should_receive(:run)
|
|
|
|
.with(config)
|
|
|
|
.and_return(runner)
|
2012-08-28 13:43:15 -04:00
|
|
|
should be(1)
|
|
|
|
end
|
2012-08-28 12:57:39 -04:00
|
|
|
end
|
2013-01-21 17:54:25 -05:00
|
|
|
|
2012-08-28 12:57:39 -04:00
|
|
|
end
|