2014-12-12 20:06:04 -05:00
|
|
|
RSpec.describe 'rspec integration', mutant: false do
|
2012-10-26 05:24:29 -04:00
|
|
|
|
2014-03-08 13:01:17 -05:00
|
|
|
let(:base_cmd) { 'bundle exec mutant -I lib --require test_app --use rspec' }
|
2014-03-03 13:00:57 -05:00
|
|
|
|
|
|
|
shared_examples_for 'rspec integration' do
|
|
|
|
around do |example|
|
|
|
|
Bundler.with_clean_env do
|
|
|
|
Dir.chdir(TestApp.root) do
|
2014-05-22 21:17:54 -04:00
|
|
|
Kernel.system("bundle install --gemfile=#{gemfile}") || fail('Bundle install failed!')
|
2014-03-04 15:10:23 -05:00
|
|
|
ENV['BUNDLE_GEMFILE'] = gemfile
|
2014-03-03 13:00:57 -05:00
|
|
|
example.run
|
|
|
|
end
|
|
|
|
end
|
2012-08-14 06:27:56 -04:00
|
|
|
end
|
|
|
|
|
2014-03-03 13:00:57 -05:00
|
|
|
specify 'it allows to kill mutations' do
|
2014-06-08 14:12:16 -04:00
|
|
|
expect(Kernel.system("#{base_cmd} TestApp::Literal#string")).to be(true)
|
2014-03-03 13:00:57 -05:00
|
|
|
end
|
2013-09-13 19:17:14 -04:00
|
|
|
|
2014-03-03 13:00:57 -05:00
|
|
|
specify 'it allows to exclude mutations' do
|
|
|
|
cli = <<-CMD.split("\n").join(' ')
|
|
|
|
#{base_cmd}
|
2014-06-08 14:12:16 -04:00
|
|
|
TestApp::Literal#string
|
|
|
|
TestApp::Literal#uncovered_string
|
|
|
|
--ignore-subject TestApp::Literal#uncovered_string
|
2014-03-03 13:00:57 -05:00
|
|
|
CMD
|
|
|
|
expect(Kernel.system(cli)).to be(true)
|
|
|
|
end
|
2012-08-14 06:27:56 -04:00
|
|
|
|
2014-03-03 13:00:57 -05:00
|
|
|
specify 'fails to kill mutations when they are not covered' do
|
2014-06-08 14:12:16 -04:00
|
|
|
cli = "#{base_cmd} TestApp::Literal#uncovered_string"
|
2014-03-03 13:00:57 -05:00
|
|
|
expect(Kernel.system(cli)).to be(false)
|
|
|
|
end
|
|
|
|
|
|
|
|
specify 'fails when some mutations are not covered' do
|
2014-06-08 14:12:16 -04:00
|
|
|
cli = "#{base_cmd} TestApp::Literal"
|
2014-03-03 13:00:57 -05:00
|
|
|
expect(Kernel.system(cli)).to be(false)
|
|
|
|
end
|
2013-09-13 16:28:04 -04:00
|
|
|
end
|
|
|
|
|
2014-10-28 05:59:12 -04:00
|
|
|
context 'RSpec 3.0' do
|
|
|
|
let(:gemfile) { 'Gemfile.rspec3.0' }
|
|
|
|
|
|
|
|
it_behaves_like 'rspec integration'
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'RSpec 3.1' do
|
|
|
|
let(:gemfile) { 'Gemfile.rspec3.1' }
|
2014-03-03 13:00:57 -05:00
|
|
|
|
|
|
|
it_behaves_like 'rspec integration'
|
2012-11-24 11:39:27 -05:00
|
|
|
end
|
2012-08-14 06:27:56 -04:00
|
|
|
end
|