free_mutant/spec/unit/mutant/result/env_spec.rb
2015-07-21 20:38:23 +00:00

90 lines
1.7 KiB
Ruby

RSpec.describe Mutant::Result::Env do
let(:object) do
described_class.new(
runtime: double('Runtime'),
env: env,
subject_results: [subject_result]
)
end
let(:env) do
double(
'Env',
config: config,
subjects: [double('Subject')],
mutations: [double('Mutation')]
)
end
let(:config) do
double(
'Config',
expected_coverage: Rational(1, 1)
)
end
let(:subject_result) do
double(
'Subject Result',
amount_mutation_results: results,
amount_mutations_killed: killed,
success?: true
)
end
let(:results) { 1 }
let(:killed) { 0 }
describe '#success?' do
subject { object.success? }
context 'when coverage matches expectation' do
let(:killed) { 1 }
it { should be(true) }
end
context 'when coverage does not match expectation' do
it { should be(false) }
end
end
describe '#failed_subject_results' do
subject { object.failed_subject_results }
it { should eql([]) }
end
describe '#coverage' do
subject { object.coverage }
context 'when there are no results' do
let(:results) { 0 }
it { should eql(Rational(1)) }
end
context 'when there are no kills' do
it { should eql(Rational(0)) }
end
context 'when there are kills' do
let(:killed) { 1 }
let(:results) { 2 }
it { should eql(Rational(1, 2)) }
end
end
describe '#amount_mutations' do
subject { object.amount_mutations }
it { should eql(1) }
end
describe '#amount_subjects' do
subject { object.amount_subjects }
it { should eql(1) }
end
end