free_mutant/spec/integration/mutant/rspec_spec.rb

53 lines
1.4 KiB
Ruby
Raw Normal View History

RSpec.describe 'rspec integration' do
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
Kernel.system("bundle install --gemfile=#{gemfile}") || fail('Bundle install failed!')
ENV['BUNDLE_GEMFILE'] = gemfile
2014-03-03 13:00:57 -05:00
example.run
end
end
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)
2014-03-03 13:00:57 -05:00
end
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
2014-03-03 13:00:57 -05:00
CMD
expect(Kernel.system(cli)).to be(true)
end
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"
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
cli = "#{base_cmd} TestApp::Literal"
2014-03-03 13:00:57 -05:00
expect(Kernel.system(cli)).to be(false)
end
end
2014-03-03 13:00:57 -05:00
context 'RSpec 2' do
let(:gemfile) { 'Gemfile.rspec2' }
it_behaves_like 'rspec integration'
end
2012-11-24 11:39:27 -05:00
2014-05-23 16:21:09 -04:00
context 'RSpec 3' do
2014-03-03 13:00:57 -05:00
let(:gemfile) { 'Gemfile.rspec3' }
it_behaves_like 'rspec integration'
2012-11-24 11:39:27 -05:00
end
end