Kill remaining mutations in Env
This commit is contained in:
parent
b3550e6792
commit
b41f1feadc
2 changed files with 60 additions and 33 deletions
47
spec/unit/mutant/env/boostrap_spec.rb
vendored
47
spec/unit/mutant/env/boostrap_spec.rb
vendored
|
@ -41,12 +41,18 @@ RSpec.describe Mutant::Env::Bootstrap do
|
|||
it { should eql(expected_env) }
|
||||
end
|
||||
|
||||
def expect_warning
|
||||
expect(config.reporter).to receive(:warn)
|
||||
.with(expected_warning)
|
||||
.and_return(config.reporter)
|
||||
end
|
||||
|
||||
before do
|
||||
expect(integration_class).to receive(:new)
|
||||
.with(config)
|
||||
.and_return(integration)
|
||||
|
||||
expect(integration).to receive(:setup).and_return(integration)
|
||||
expect(integration).to receive_messages(setup: integration)
|
||||
|
||||
expect(ObjectSpace).to receive(:each_object)
|
||||
.with(Module)
|
||||
|
@ -54,16 +60,12 @@ RSpec.describe Mutant::Env::Bootstrap do
|
|||
end
|
||||
|
||||
describe '#warn' do
|
||||
let(:object) { described_class.new(config) }
|
||||
let(:message) { instance_double(String) }
|
||||
let(:object) { described_class.new(config) }
|
||||
let(:expected_warning) { instance_double(String) }
|
||||
|
||||
subject { object.warn(message) }
|
||||
subject { object.warn(expected_warning) }
|
||||
|
||||
before do
|
||||
expect(config.reporter).to receive(:warn)
|
||||
.with(message)
|
||||
.and_return(config.reporter)
|
||||
end
|
||||
before { expect_warning }
|
||||
|
||||
it_behaves_like 'a command method'
|
||||
end
|
||||
|
@ -74,6 +76,11 @@ RSpec.describe Mutant::Env::Bootstrap do
|
|||
context 'when Module#name calls result in exceptions' do
|
||||
let(:object_space_modules) { [invalid_class] }
|
||||
|
||||
let(:expected_warning) do
|
||||
"Class#name from: #{invalid_class} raised an error: " \
|
||||
"RuntimeError. #{Mutant::Env::SEMANTICS_MESSAGE}"
|
||||
end
|
||||
|
||||
let(:invalid_class) do
|
||||
Class.new do
|
||||
def self.name
|
||||
|
@ -91,15 +98,7 @@ RSpec.describe Mutant::Env::Bootstrap do
|
|||
end
|
||||
end
|
||||
|
||||
before do
|
||||
expected_warning =
|
||||
"Class#name from: #{invalid_class} raised an error: " \
|
||||
"RuntimeError. #{Mutant::Env::SEMANTICS_MESSAGE}"
|
||||
|
||||
expect(config.reporter).to receive(:warn)
|
||||
.with(expected_warning)
|
||||
.and_return(config.reporter)
|
||||
end
|
||||
before { expect_warning }
|
||||
|
||||
include_examples 'bootstrap call'
|
||||
end
|
||||
|
@ -143,6 +142,11 @@ RSpec.describe Mutant::Env::Bootstrap do
|
|||
end
|
||||
end
|
||||
|
||||
let(:expected_warning) do
|
||||
"Class#name from: #{invalid_class} " \
|
||||
"returned Object. #{Mutant::Env::SEMANTICS_MESSAGE}"
|
||||
end
|
||||
|
||||
after do
|
||||
# Fix Class#name so other specs do not see this one
|
||||
class << invalid_class
|
||||
|
@ -152,12 +156,7 @@ RSpec.describe Mutant::Env::Bootstrap do
|
|||
end
|
||||
end
|
||||
|
||||
before do
|
||||
expected_warning =
|
||||
"Class#name from: #{invalid_class.inspect} returned Object. #{Mutant::Env::SEMANTICS_MESSAGE}"
|
||||
|
||||
expect(config.reporter).to receive(:warn).with(expected_warning).and_return(config.reporter)
|
||||
end
|
||||
before { expect_warning }
|
||||
|
||||
include_examples 'bootstrap call'
|
||||
end
|
||||
|
|
|
@ -13,7 +13,7 @@ RSpec.describe Mutant::Env do
|
|||
)
|
||||
end
|
||||
|
||||
let(:integration) { integration_class.new(config) }
|
||||
let(:integration) { instance_double(Mutant::Integration) }
|
||||
|
||||
let(:config) do
|
||||
Mutant::Config::DEFAULT.with(isolation: isolation, integration: integration_class)
|
||||
|
@ -45,18 +45,38 @@ RSpec.describe Mutant::Env do
|
|||
end
|
||||
|
||||
before do
|
||||
expect(selector).to receive(:call).with(mutation_subject).and_return(tests)
|
||||
allow(Time).to receive(:now).and_return(Time.at(0))
|
||||
expect(selector).to receive(:call)
|
||||
.with(mutation_subject)
|
||||
.and_return(tests)
|
||||
|
||||
allow(Time).to receive_messages(now: Time.at(0))
|
||||
end
|
||||
|
||||
context 'when isolation does not raise error' do
|
||||
let(:test_result) { instance_double(Mutant::Result::Test, passed: false) }
|
||||
|
||||
before do
|
||||
expect(isolation).to receive(:call).and_yield.and_return(test_result)
|
||||
expect(mutation_subject).to receive(:prepare).and_return(mutation_subject).ordered
|
||||
expect(context).to receive(:root).with(s(:nil)).and_return(wrapped_node).ordered
|
||||
expect(Mutant::Loader::Eval).to receive(:call).with(wrapped_node, mutation_subject).and_return(nil).ordered
|
||||
expect(isolation).to receive(:call)
|
||||
.ordered
|
||||
.and_yield
|
||||
|
||||
expect(mutation_subject).to receive(:prepare)
|
||||
.ordered
|
||||
.and_return(mutation_subject)
|
||||
|
||||
expect(context).to receive(:root)
|
||||
.with(s(:nil))
|
||||
.and_return(wrapped_node)
|
||||
|
||||
expect(Mutant::Loader::Eval).to receive(:call)
|
||||
.ordered
|
||||
.with(wrapped_node, mutation_subject)
|
||||
.and_return(Mutant::Loader::Eval)
|
||||
|
||||
expect(integration).to receive(:call)
|
||||
.ordered
|
||||
.with(tests)
|
||||
.and_return(test_result)
|
||||
end
|
||||
|
||||
include_examples 'mutation kill'
|
||||
|
@ -64,10 +84,18 @@ RSpec.describe Mutant::Env do
|
|||
|
||||
context 'when isolation does raise error' do
|
||||
before do
|
||||
expect(isolation).to receive(:call).and_raise(Mutant::Isolation::Error, 'test-error')
|
||||
expect(isolation).to receive(:call)
|
||||
.and_raise(Mutant::Isolation::Error, 'test-error')
|
||||
end
|
||||
|
||||
let(:test_result) { Mutant::Result::Test.new(tests: tests, output: 'test-error', passed: false, runtime: 0.0) }
|
||||
let(:test_result) do
|
||||
Mutant::Result::Test.new(
|
||||
tests: tests,
|
||||
output: 'test-error',
|
||||
passed: false,
|
||||
runtime: 0.0
|
||||
)
|
||||
end
|
||||
|
||||
include_examples 'mutation kill'
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue