Sha256: 337ff6b78f574b9890565d3790ea226eb4c4a8221f4f5c5f358b25a091b6c76d
Contents?: true
Size: 1.04 KB
Versions: 19
Compression:
Stored size: 1.04 KB
Contents
# frozen_string_literal: true require_relative 'helper' class KernelTest < MiniTest::Test def test_system_method fn = '/tmp/test_system_method' FileUtils.rm(fn) rescue nil counter = 0 timer = spin { throttled_loop(200) { counter += 1 } } system('sleep 0.01') assert(counter >= 2) system('echo "hello" > ' + fn) assert_equal "hello\n", IO.read(fn) ensure timer&.stop end def patch_open3 class << Open3 alias_method :orig_popen2, :popen2 def popen2(*args) raise SystemCallError, 'foo' end end end def unpatch_open3 class << Open3 alias_method :popen2, :orig_popen2 end end def test_system_method_with_system_call_error patch_open3 result = system('foo') assert_nil result ensure unpatch_open3 end def test_backtick_method counter = 0 timer = spin { throttled_loop(200) { counter += 1 } } `sleep 0.01` assert(counter >= 2) result = `echo "hello"` assert_equal "hello\n", result ensure timer&.stop end end
Version data entries
19 entries across 19 versions & 1 rubygems