Sha256: 4c3231c4928779e60d711f6bdb55ddb9e1d08fa182a1a2878a11b05ca20e12d0

Contents?: true

Size: 884 Bytes

Versions: 25

Compression:

Stored size: 884 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

Version data entries

25 entries across 23 versions & 3 rubygems

Version Path
rubocop-0.64.0 lib/rubocop/rspec/host_environment_simulation_helper.rb
rubocop-0.63.1 lib/rubocop/rspec/host_environment_simulation_helper.rb
rubocop-0.63.0 lib/rubocop/rspec/host_environment_simulation_helper.rb
rubocop-0.62.0 lib/rubocop/rspec/host_environment_simulation_helper.rb
rubocop-0.61.1 lib/rubocop/rspec/host_environment_simulation_helper.rb
rubocop-0.61.0 lib/rubocop/rspec/host_environment_simulation_helper.rb
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/config_gems_initialization_aim-0.1.1/vendor/bundle/ruby/2.5.0/gems/rubocop-0.60.0/lib/rubocop/rspec/host_environment_simulation_helper.rb
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/rubocop-0.60.0/lib/rubocop/rspec/host_environment_simulation_helper.rb
config_gems_initialization_aim-0.1.3 vendor/bundle/ruby/2.5.0/gems/config_gems_initialization_aim-0.1.1/vendor/bundle/ruby/2.5.0/gems/rubocop-0.60.0/lib/rubocop/rspec/host_environment_simulation_helper.rb
config_gems_initialization_aim-0.1.3 vendor/bundle/ruby/2.5.0/gems/rubocop-0.60.0/lib/rubocop/rspec/host_environment_simulation_helper.rb
rubocop-0.60.0 lib/rubocop/rspec/host_environment_simulation_helper.rb
rubocop-0.59.2 lib/rubocop/rspec/host_environment_simulation_helper.rb
rubocop-0.59.1 lib/rubocop/rspec/host_environment_simulation_helper.rb
rubocop-0.59.0 lib/rubocop/rspec/host_environment_simulation_helper.rb
rubocop-0.58.2 lib/rubocop/rspec/host_environment_simulation_helper.rb
rubocop-0.58.1 lib/rubocop/rspec/host_environment_simulation_helper.rb
rubocop-0.58.0 lib/rubocop/rspec/host_environment_simulation_helper.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/rubocop-0.57.2/lib/rubocop/rspec/host_environment_simulation_helper.rb
rubocop-0.57.2 lib/rubocop/rspec/host_environment_simulation_helper.rb
rubocop-0.57.1 lib/rubocop/rspec/host_environment_simulation_helper.rb