Test both rspec 2 and 3
This commit is contained in:
parent
9f0dbeebe2
commit
30092dd956
4 changed files with 43 additions and 23 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -33,6 +33,7 @@ measurements
|
||||||
## BUNDLER
|
## BUNDLER
|
||||||
.bundle
|
.bundle
|
||||||
Gemfile.lock
|
Gemfile.lock
|
||||||
|
Gemfile.*.lock
|
||||||
|
|
||||||
## PROJECT::SPECIFIC
|
## PROJECT::SPECIFIC
|
||||||
/vendor
|
/vendor
|
||||||
|
|
|
@ -4,35 +4,52 @@ require 'spec_helper'
|
||||||
|
|
||||||
describe Mutant, 'rspec integration' do
|
describe Mutant, 'rspec integration' do
|
||||||
|
|
||||||
around do |example|
|
let(:base_cmd) { "bundle exec mutant -I lib --require test_app --use rspec" }
|
||||||
Dir.chdir(TestApp.root) do
|
|
||||||
example.run
|
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
|
||||||
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:base_cmd) { 'bundle exec mutant -I lib --require test_app --use rspec' }
|
context 'RSpec 2' do
|
||||||
|
let(:gemfile) { 'Gemfile.rspec2' }
|
||||||
|
|
||||||
specify 'it allows to kill mutations' do
|
it_behaves_like 'rspec integration'
|
||||||
expect(Kernel.system("#{base_cmd} ::TestApp::Literal#string")).to be(true)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
specify 'it allows to exclude mutations' do
|
context 'Rspec 3' do
|
||||||
cli = <<-CMD.split("\n").join(' ')
|
let(:gemfile) { 'Gemfile.rspec3' }
|
||||||
#{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
|
it_behaves_like 'rspec integration'
|
||||||
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
|
||||||
end
|
end
|
||||||
|
|
1
test_app/Gemfile.rspec2
Normal file
1
test_app/Gemfile.rspec2
Normal file
|
@ -0,0 +1 @@
|
||||||
|
gem 'rspec', '~> 2.14.1'
|
1
test_app/Gemfile.rspec3
Normal file
1
test_app/Gemfile.rspec3
Normal file
|
@ -0,0 +1 @@
|
||||||
|
gem 'rspec', '~> 3.0.0.beta2'
|
Loading…
Add table
Reference in a new issue