Sha256: 6c03a384203d95cc62cdca5b5ee824840243b37d148a30f29b055199ce5878cf

Contents?: true

Size: 965 Bytes

Versions: 18

Compression:

Stored size: 965 Bytes

Contents

# frozen_string_literal: true

# RuboCop can be run in contexts where unexpected other libraries are included,
# which may interfere with its normal behavior. In order to test those
# situations, it may be necessary to require another library for the duration
# of one spec
module HostEnvironmentSimulatorHelper
  def in_its_own_process_with(*files)
    if ::Process.respond_to?(:fork)
      pid = ::Process.fork do
        # Need to write coverage result under different name
        if defined?(SimpleCov)
          SimpleCov.coverage_dir "coverage/ignored_results_#{Process.pid}"
          SimpleCov.pid = Process.pid
        end

        files.each { |file| require file }
        yield
      end
      ::Process.wait(pid)

      # assert that the block did not fail
      expect($CHILD_STATUS).to be_success
    else
      warn 'Process.fork is not available.'
    end
  end
end

RSpec.configure do |config|
  config.include HostEnvironmentSimulatorHelper
end

Version data entries

18 entries across 18 versions & 2 rubygems

Version Path
dirwatch-0.0.9 vendor/bundle/ruby/2.5.0/gems/rubocop-0.46.0/lib/rubocop/rspec/host_environment_simulation_helper.rb
dirwatch-0.0.8 vendor/bundle/ruby/2.5.0/gems/rubocop-0.46.0/lib/rubocop/rspec/host_environment_simulation_helper.rb
rubocop-0.52.1 lib/rubocop/rspec/host_environment_simulation_helper.rb
rubocop-0.52.0 lib/rubocop/rspec/host_environment_simulation_helper.rb
dirwatch-0.0.6 vendor/bundle/ruby/2.3.0/gems/rubocop-0.46.0/lib/rubocop/rspec/host_environment_simulation_helper.rb
dirwatch-0.0.5 vendor/bundle/ruby/2.3.0/gems/rubocop-0.46.0/lib/rubocop/rspec/host_environment_simulation_helper.rb
dirwatch-0.0.4 vendor/bundle/ruby/2.3.0/gems/rubocop-0.46.0/lib/rubocop/rspec/host_environment_simulation_helper.rb
dirwatch-0.0.3 vendor/bundle/ruby/2.3.0/gems/rubocop-0.46.0/lib/rubocop/rspec/host_environment_simulation_helper.rb
dirwatch-0.0.2 vendor/bundle/ruby/2.3.0/gems/rubocop-0.46.0/lib/rubocop/rspec/host_environment_simulation_helper.rb
rubocop-0.51.0 lib/rubocop/rspec/host_environment_simulation_helper.rb
rubocop-0.50.0 lib/rubocop/rspec/host_environment_simulation_helper.rb
rubocop-0.49.1 lib/rubocop/rspec/host_environment_simulation_helper.rb
rubocop-0.49.0 lib/rubocop/rspec/host_environment_simulation_helper.rb
rubocop-0.48.1 lib/rubocop/rspec/host_environment_simulation_helper.rb
rubocop-0.48.0 lib/rubocop/rspec/host_environment_simulation_helper.rb
rubocop-0.47.1 lib/rubocop/rspec/host_environment_simulation_helper.rb
rubocop-0.47.0 lib/rubocop/rspec/host_environment_simulation_helper.rb
rubocop-0.46.0 lib/rubocop/rspec/host_environment_simulation_helper.rb