2013-12-29 23:29:58 +01:00
|
|
|
# encoding: utf-8
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Mutant::Runner::Config do
|
|
|
|
|
|
|
|
let(:config) do
|
2014-01-19 00:06:40 +01:00
|
|
|
Mutant::Config.new(
|
|
|
|
matcher: [subject_a, subject_b],
|
|
|
|
cache: Mutant::Cache.new,
|
|
|
|
debug: false,
|
|
|
|
strategy: strategy,
|
|
|
|
reporter: reporter,
|
|
|
|
fail_fast: fail_fast,
|
|
|
|
expected_coverage: expected_coverage,
|
2014-02-02 22:48:08 +01:00
|
|
|
zombie: false
|
2013-12-29 23:29:58 +01:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2014-01-19 00:06:40 +01:00
|
|
|
let(:fail_fast) { false }
|
|
|
|
let(:expected_coverage) { 100.0 }
|
|
|
|
|
2013-12-29 23:29:58 +01:00
|
|
|
before do
|
|
|
|
reporter.stub(report: reporter)
|
|
|
|
strategy.stub(:setup)
|
|
|
|
strategy.stub(:teardown)
|
|
|
|
Mutant::Runner.stub(:run).with(config, subject_a).and_return(runner_a)
|
|
|
|
Mutant::Runner.stub(:run).with(config, subject_b).and_return(runner_b)
|
|
|
|
end
|
|
|
|
|
|
|
|
let(:reporter) { double('Reporter') }
|
|
|
|
let(:strategy) { double('Strategy') }
|
|
|
|
let(:subject_a) { double('Subject A') }
|
|
|
|
let(:subject_b) { double('Subject B') }
|
|
|
|
|
|
|
|
describe '#subjects' do
|
|
|
|
let(:object) { described_class.run(config) }
|
|
|
|
|
|
|
|
subject { object.subjects }
|
|
|
|
|
|
|
|
let(:runner_a) { double('Runner A', stop?: stop_a) }
|
|
|
|
let(:runner_b) { double('Runner B', stop?: stop_b) }
|
|
|
|
|
|
|
|
context 'without early stop' do
|
|
|
|
let(:stop_a) { false }
|
|
|
|
let(:stop_b) { false }
|
|
|
|
|
|
|
|
it { should eql([runner_a, runner_b]) }
|
|
|
|
|
|
|
|
it_should_behave_like 'an idempotent method'
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with early stop' do
|
|
|
|
let(:stop_a) { true }
|
|
|
|
let(:stop_b) { false }
|
|
|
|
|
|
|
|
it { should eql([runner_a]) }
|
|
|
|
|
|
|
|
it_should_behave_like 'an idempotent method'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#success?' do
|
|
|
|
subject { object.success? }
|
|
|
|
|
|
|
|
let(:object) { described_class.new(config) }
|
|
|
|
|
2014-01-19 00:06:40 +01:00
|
|
|
let(:mutation_a) do
|
|
|
|
double('Mutation A', success?: false)
|
|
|
|
end
|
|
|
|
|
|
|
|
let(:mutation_b) do
|
|
|
|
double('Mutation B', success?: true)
|
|
|
|
end
|
|
|
|
|
2013-12-29 23:29:58 +01:00
|
|
|
let(:runner_a) do
|
2014-01-19 00:06:40 +01:00
|
|
|
double('Runner A', stop?: false, success?: false, mutations: [mutation_a])
|
2013-12-29 23:29:58 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
let(:runner_b) do
|
2014-01-19 00:06:40 +01:00
|
|
|
double('Runner B', stop?: false, success?: true, mutations: [mutation_b])
|
2013-12-29 23:29:58 +01:00
|
|
|
end
|
|
|
|
|
2014-01-19 00:06:40 +01:00
|
|
|
context 'without fail fast' do
|
2013-12-29 23:29:58 +01:00
|
|
|
|
2014-01-19 00:06:40 +01:00
|
|
|
context 'when expected coverage equals actual coverage' do
|
|
|
|
let(:expected_coverage) { 50.0 }
|
|
|
|
it { should be(true) }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when expected coverage closely equals actual coverage' do
|
|
|
|
let(:expected_coverage) { 50.01 }
|
|
|
|
it { should be(true) }
|
|
|
|
end
|
2013-12-29 23:29:58 +01:00
|
|
|
|
2014-01-19 00:06:40 +01:00
|
|
|
context 'when expected coverage does not equal actual coverage' do
|
|
|
|
let(:expected_coverage) { 51.00 }
|
|
|
|
it { should be(false) }
|
|
|
|
end
|
2013-12-29 23:29:58 +01:00
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|