Module: HostEnvironmentSimulatorHelper
- Defined in:
- lib/rubocop/rspec/host_environment_simulation_helper.rb
Overview
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
Instance Method Summary collapse
Instance Method Details
#in_its_own_process_with(*files) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/rubocop/rspec/host_environment_simulation_helper.rb', line 8 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 |