Move framework integration into own behavior
This commit is contained in:
parent
7529b724c4
commit
87284a368e
2 changed files with 38 additions and 39 deletions
|
@ -2,57 +2,21 @@ RSpec.describe 'rspec integration', mutant: false do
|
|||
|
||||
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}") || fail('Bundle install failed!')
|
||||
ENV['BUNDLE_GEMFILE'] = gemfile
|
||||
example.run
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
specify 'it allows to kill mutations' do
|
||||
expect(Kernel.system("#{base_cmd} TestApp::Literal#string")).to be(true)
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
end
|
||||
|
||||
context 'RSpec 3.0' do
|
||||
let(:gemfile) { 'Gemfile.rspec3.0' }
|
||||
|
||||
it_behaves_like 'rspec integration'
|
||||
it_behaves_like 'framework integration'
|
||||
end
|
||||
|
||||
context 'RSpec 3.1' do
|
||||
let(:gemfile) { 'Gemfile.rspec3.1' }
|
||||
|
||||
it_behaves_like 'rspec integration'
|
||||
it_behaves_like 'framework integration'
|
||||
end
|
||||
|
||||
context 'RSpec 3.2' do
|
||||
let(:gemfile) { 'Gemfile.rspec3.2' }
|
||||
|
||||
it_behaves_like 'rspec integration'
|
||||
it_behaves_like 'framework integration'
|
||||
end
|
||||
end
|
||||
|
|
35
spec/shared/framework_integration_behavior.rb
Normal file
35
spec/shared/framework_integration_behavior.rb
Normal file
|
@ -0,0 +1,35 @@
|
|||
RSpec.shared_examples_for 'framework integration' do
|
||||
around do |example|
|
||||
Bundler.with_clean_env do
|
||||
Dir.chdir(TestApp.root) do
|
||||
Kernel.system("bundle install --gemfile=#{gemfile}") || fail('Bundle install failed!')
|
||||
ENV['BUNDLE_GEMFILE'] = gemfile
|
||||
example.run
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
specify 'it allows to kill mutations' do
|
||||
expect(Kernel.system("#{base_cmd} TestApp::Literal#string")).to be(true)
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
end
|
Loading…
Add table
Reference in a new issue