2012-08-28 12:57:39 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Mutant::CLI, '.run' do
|
|
|
|
subject { object.run(argv) }
|
|
|
|
|
2013-02-24 14:40:23 -05:00
|
|
|
let(:object) { described_class }
|
|
|
|
let(:argv) { mock('ARGV') }
|
|
|
|
let(:attributes) { mock('Options') }
|
|
|
|
let(:runner) { mock('Runner', :success? => success) }
|
|
|
|
let(:config) { mock('Config') }
|
|
|
|
let(:instance) { mock(described_class.name, :config => config) }
|
2012-08-28 12:57:39 -04:00
|
|
|
|
|
|
|
before do
|
|
|
|
described_class.stub(:new => instance)
|
2013-02-02 10:32:13 -05:00
|
|
|
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-02-24 14:40:23 -05: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-02-24 14:40:23 -05: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
|