2012-08-28 12:57:39 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Mutant::CLI, '.run' do
|
|
|
|
subject { object.run(argv) }
|
|
|
|
|
2012-09-15 18:51:47 -04:00
|
|
|
let(:object) { described_class }
|
|
|
|
let(:argv) { mock('ARGV') }
|
|
|
|
let(:attributes) { mock('Options') }
|
2013-01-21 17:54:25 -05:00
|
|
|
let(:runner) { mock('Runner', :success? => success) }
|
2012-09-15 18:51:47 -04:00
|
|
|
let(:instance) { mock(described_class.name, :attributes => attributes) }
|
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-02 10:32:13 -05:00
|
|
|
Mutant::Runner::Config.should_receive(:run).with(instance).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-02 10:32:13 -05:00
|
|
|
Mutant::Runner::Config.should_receive(:run).with(instance).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
|