2013-07-28 19:03:06 -04:00
|
|
|
# encoding: utf-8
|
|
|
|
|
2012-08-14 06:27:56 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2013-07-28 15:16:45 -04:00
|
|
|
describe Mutant, 'rspec integration' do
|
2012-10-26 05:24:29 -04:00
|
|
|
|
2014-03-03 13:00:57 -05:00
|
|
|
let(:base_cmd) { "bundle exec mutant -I lib --require test_app --use rspec" }
|
|
|
|
|
|
|
|
shared_examples_for 'rspec integration' do
|
|
|
|
around do |example|
|
|
|
|
Bundler.with_clean_env do
|
|
|
|
Dir.chdir(TestApp.root) do
|
|
|
|
Kernel.system("bundle install --gemfile=#{gemfile}")
|
|
|
|
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
|
|
|
|
expect(Kernel.system("#{base_cmd} ::TestApp::Literal#string")).to be(true)
|
|
|
|
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}
|
|
|
|
::TestApp::Literal#string
|
|
|
|
::TestApp::Literal#uncovered_string
|
|
|
|
--ignore-subject ::TestApp::Literal#uncovered_string
|
|
|
|
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
|
|
|
|
cli = "#{base_cmd} ::TestApp::Literal#uncovered_string"
|
|
|
|
expect(Kernel.system(cli)).to be(false)
|
|
|
|
end
|
|
|
|
|
|
|
|
specify 'fails when some mutations are not covered' do
|
|
|
|
cli = "#{base_cmd} ::TestApp::Literal"
|
|
|
|
expect(Kernel.system(cli)).to be(false)
|
|
|
|
end
|
2013-09-13 16:28:04 -04:00
|
|
|
end
|
|
|
|
|
2014-03-03 13:00:57 -05:00
|
|
|
context 'RSpec 2' do
|
|
|
|
let(:gemfile) { 'Gemfile.rspec2' }
|
|
|
|
|
|
|
|
it_behaves_like 'rspec integration'
|
2012-08-14 06:27:56 -04:00
|
|
|
end
|
2012-11-24 11:39:27 -05:00
|
|
|
|
2014-03-03 13:00:57 -05:00
|
|
|
context 'Rspec 3' do
|
|
|
|
let(:gemfile) { 'Gemfile.rspec3' }
|
|
|
|
|
|
|
|
it_behaves_like 'rspec integration'
|
2012-11-24 11:39:27 -05:00
|
|
|
end
|
2012-08-14 06:27:56 -04:00
|
|
|
end
|