2018-09-12 14:21:24 +00:00
|
|
|
# frozen_string_literal: true
|
2018-09-12 13:15:43 +00:00
|
|
|
|
2015-04-26 13:04:52 -04:00
|
|
|
RSpec.shared_examples_for 'framework integration' do
|
2017-07-06 09:45:17 +02:00
|
|
|
def system_with_gemfile(*command)
|
|
|
|
Kernel.system({ 'BUNDLE_GEMFILE' => gemfile }, *command)
|
|
|
|
end
|
|
|
|
|
2015-04-26 13:04:52 -04:00
|
|
|
around do |example|
|
2018-11-19 12:04:01 +00:00
|
|
|
Bundler.with_clean_env do
|
|
|
|
Dir.chdir(TestApp.root) do
|
|
|
|
Kernel.system('bundle', 'install', '--gemfile', gemfile) || fail('Bundle install failed!')
|
|
|
|
example.run
|
|
|
|
end
|
2015-04-26 13:04:52 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
specify 'it allows to kill mutations' do
|
2018-11-19 12:04:01 +00:00
|
|
|
expect(system_with_gemfile("#{base_cmd} TestApp::Literal#string")).to be(true)
|
2015-04-26 13:04:52 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
specify 'it allows to exclude mutations' do
|
|
|
|
cli = <<-CMD.split("\n").join(' ')
|
|
|
|
#{base_cmd}
|
2018-11-19 12:04:02 +00:00
|
|
|
--ignore-subject TestApp::Literal#uncovered_string
|
|
|
|
--
|
2015-04-26 13:04:52 -04:00
|
|
|
TestApp::Literal#string
|
|
|
|
TestApp::Literal#uncovered_string
|
|
|
|
CMD
|
2017-07-06 09:45:17 +02:00
|
|
|
expect(system_with_gemfile(cli)).to be(true)
|
2015-04-26 13:04:52 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
specify 'fails to kill mutations when they are not covered' do
|
|
|
|
cli = "#{base_cmd} TestApp::Literal#uncovered_string"
|
2017-07-06 09:45:17 +02:00
|
|
|
expect(system_with_gemfile(cli)).to be(false)
|
2015-04-26 13:04:52 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
specify 'fails when some mutations are not covered' do
|
|
|
|
cli = "#{base_cmd} TestApp::Literal"
|
2017-07-06 09:45:17 +02:00
|
|
|
expect(system_with_gemfile(cli)).to be(false)
|
2015-04-26 13:04:52 -04:00
|
|
|
end
|
|
|
|
end
|