|
1 | 1 | # frozen_string_literal: true
|
2 | 2 |
|
3 | 3 | RSpec.describe Mutant::Env do
|
4 |
| - let(:object) do |
| 4 | + subject do |
5 | 5 | described_class.new(
|
6 | 6 | config: config,
|
7 | 7 | integration: integration,
|
|
19 | 19 | let(:isolation) { Mutant::Isolation::None.new }
|
20 | 20 | let(:kernel) { instance_double(Object, 'kernel') }
|
21 | 21 | let(:mutation_subject) { instance_double(Mutant::Subject) }
|
| 22 | + let(:reporter) { instance_double(Mutant::Reporter) } |
22 | 23 | let(:selector) { instance_double(Mutant::Selector) }
|
23 | 24 | let(:test_a) { instance_double(Mutant::Test) }
|
24 | 25 | let(:test_b) { instance_double(Mutant::Test) }
|
|
32 | 33 | end
|
33 | 34 |
|
34 | 35 | let(:config) do
|
35 |
| - Mutant::Config::DEFAULT.with( |
| 36 | + instance_double( |
| 37 | + Mutant::Config, |
| 38 | + integration: integration_class, |
36 | 39 | isolation: isolation,
|
37 |
| - integration: integration_class |
| 40 | + reporter: reporter |
38 | 41 | )
|
39 | 42 | end
|
40 | 43 |
|
|
55 | 58 |
|
56 | 59 | describe '#kill' do
|
57 | 60 | def apply
|
58 |
| - object.kill(mutation) |
| 61 | + subject.kill(mutation) |
59 | 62 | end
|
60 | 63 |
|
61 | 64 | before do
|
@@ -120,10 +123,34 @@ def apply
|
120 | 123 | end
|
121 | 124 |
|
122 | 125 | describe '#selections' do
|
123 |
| - subject { object.selections } |
| 126 | + def apply |
| 127 | + subject.selections |
| 128 | + end |
124 | 129 |
|
125 | 130 | it 'returns expected selections' do
|
126 |
| - expect(subject).to eql(mutation_subject => tests) |
| 131 | + expect(apply).to eql(mutation_subject => tests) |
| 132 | + end |
| 133 | + end |
| 134 | + |
| 135 | + describe '#warn' do |
| 136 | + def apply |
| 137 | + subject.warn(message) |
| 138 | + end |
| 139 | + |
| 140 | + before do |
| 141 | + allow(reporter).to receive_messages(warn: reporter) |
| 142 | + end |
| 143 | + |
| 144 | + let(:message) { 'test-warning' } |
| 145 | + |
| 146 | + it 'warns via the reporter' do |
| 147 | + apply |
| 148 | + |
| 149 | + expect(reporter).to have_received(:warn).with(message) |
| 150 | + end |
| 151 | + |
| 152 | + it 'returns self' do |
| 153 | + expect(apply).to be(subject) |
127 | 154 | end
|
128 | 155 | end
|
129 | 156 | end
|
0 commit comments