Sha256: b6a07d3d7836ce4543be63f237de3f3a43cb4e98b818b99d2a2cfbbd3a123ab3

Contents?: true

Size: 870 Bytes

Versions: 7198

Compression:

Stored size: 870 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.command_name "rspec-fork-#{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

7,198 entries across 7,161 versions & 49 rubygems

Version Path
rubocop-0.93.0 lib/rubocop/rspec/host_environment_simulation_helper.rb
rubocop-0.92.0 lib/rubocop/rspec/host_environment_simulation_helper.rb
rubocop-0.91.1 lib/rubocop/rspec/host_environment_simulation_helper.rb
rubocop-0.91.0 lib/rubocop/rspec/host_environment_simulation_helper.rb
grape-extra_validators-2.0.0 vendor/bundle/ruby/2.6.0/gems/rubocop-0.79.0/lib/rubocop/rspec/host_environment_simulation_helper.rb
grape-extra_validators-2.0.0 vendor/bundle/ruby/2.6.0/gems/rubocop-0.90.0/lib/rubocop/rspec/host_environment_simulation_helper.rb
rubocop-0.90.0 lib/rubocop/rspec/host_environment_simulation_helper.rb
rubocop-0.89.1 lib/rubocop/rspec/host_environment_simulation_helper.rb
rubocop-0.89.0 lib/rubocop/rspec/host_environment_simulation_helper.rb
rubocop-0.88.0 lib/rubocop/rspec/host_environment_simulation_helper.rb
rbhint-0.87.1.rc1 lib/rubocop/rspec/host_environment_simulation_helper.rb
rubocop-0.87.1 lib/rubocop/rspec/host_environment_simulation_helper.rb
rubocop-0.87.0 lib/rubocop/rspec/host_environment_simulation_helper.rb
rubocop-0.86.0 lib/rubocop/rspec/host_environment_simulation_helper.rb
files.com-1.0.1 vendor/bundle/ruby/2.5.0/gems/rubocop-0.85.1/lib/rubocop/rspec/host_environment_simulation_helper.rb
rbhint-0.85.1.rc2 lib/rubocop/rspec/host_environment_simulation_helper.rb
rbhint-0.85.1.rc1 lib/rubocop/rspec/host_environment_simulation_helper.rb
rubocop-0.85.1 lib/rubocop/rspec/host_environment_simulation_helper.rb
rbhint-0.8.5.rc1 lib/rubocop/rspec/host_environment_simulation_helper.rb
rubocop-0.85.0 lib/rubocop/rspec/host_environment_simulation_helper.rb