Sha256: 4bddf375705ae05c39110649a9392edfc131e4dd2e142222001f159bcdff775d

Contents?: true

Size: 1.49 KB

Versions: 12

Compression:

Stored size: 1.49 KB

Contents

# frozen_string_literal: true

RSpec.shared_examples_for 'framework integration' do
  def system_with_gemfile(*command)
    Kernel.system(
      {
        'CI'             => '1',
        'BUNDLE_GEMFILE' => gemfile
      },
      *command
    )
  end

  around do |example|
    Bundler.with_clean_env do
      Dir.chdir(TestApp.root) do
        Kernel.system('bundle', 'install', '--gemfile', gemfile) || fail('Bundle install failed!')
        example.run
      end
    end
  end

  let(:effective_base_cmd) do
    if ENV.key?('MUTANT_JOBS')
      [*base_cmd, '--jobs', ENV.fetch('MUTANT_JOBS')]
    else
      base_cmd
    end
  end

  specify 'it allows to kill mutations' do
    expect(
      system_with_gemfile(
        *effective_base_cmd,
        'TestApp::Literal#string'
      )
    ).to be(true)
  end

  specify 'it allows to exclude mutations' do
    expect(
      system_with_gemfile(
        *effective_base_cmd,
        '--ignore-subject',
        'TestApp::Literal#uncovered_string',
        '--',
        'TestApp::Literal#string',
        'TestApp::Literal#uncovered_string'
      )
    ).to be(true)
  end

  specify 'fails to kill mutations when they are not covered' do
    expect(
      system_with_gemfile(
        *effective_base_cmd,
        'TestApp::Literal#uncovered_string'
      )
    ).to be(false)
  end

  specify 'fails when some mutations are not covered' do
    expect(
      system_with_gemfile(
        *effective_base_cmd,
        'TestApp::Literal'
      )
    ).to be(false)
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
mutant-0.9.11 spec/shared/framework_integration_behavior.rb
mutant-0.9.10 spec/shared/framework_integration_behavior.rb
mutant-0.9.9 spec/shared/framework_integration_behavior.rb
mutant-0.9.8 spec/shared/framework_integration_behavior.rb
mutant-0.9.7 spec/shared/framework_integration_behavior.rb
mutant-0.9.6 spec/shared/framework_integration_behavior.rb
mutant-0.9.5 spec/shared/framework_integration_behavior.rb
mutant-0.9.4 spec/shared/framework_integration_behavior.rb
mutant-0.9.3 spec/shared/framework_integration_behavior.rb
mutant-0.9.2 spec/shared/framework_integration_behavior.rb
mutant-0.9.1 spec/shared/framework_integration_behavior.rb
mutant-0.9.0 spec/shared/framework_integration_behavior.rb