diff options
author | Takashi Kokubun <takashikkbn@gmail.com> | 2019-04-25 21:16:21 +0900 |
---|---|---|
committer | Takashi Kokubun <takashikkbn@gmail.com> | 2019-04-26 00:47:39 +0900 |
commit | 94af6cd383f9dc3ae1204a5fba8f56ee7826cbce (patch) | |
tree | 42ae2c951135341abf7b891917fa3b10c87c2707 /test/irb/test_workspace.rb | |
parent | 790f6709ae418345829d12f053cf270f4d535f1c (diff) | |
download | ruby-94af6cd383f9dc3ae1204a5fba8f56ee7826cbce.tar.gz |
Colorize IRB's code_around_binding
Closes: https://github.com/ruby/ruby/pull/2150
Diffstat (limited to 'test/irb/test_workspace.rb')
-rw-r--r-- | test/irb/test_workspace.rb | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/test/irb/test_workspace.rb b/test/irb/test_workspace.rb index 0795b17e09..9c87468cf7 100644 --- a/test/irb/test_workspace.rb +++ b/test/irb/test_workspace.rb @@ -2,6 +2,7 @@ require 'test/unit' require 'tempfile' require 'irb/workspace' +require 'irb/color' module TestIRB class TestWorkSpace < Test::Unit::TestCase @@ -18,7 +19,7 @@ module TestIRB f.close workspace = eval(code, binding, f.path) - assert_equal(<<~EOS, workspace.code_around_binding) + assert_equal(<<~EOS, without_term { workspace.code_around_binding }) From: #{f.path} @ line 3 : @@ -55,7 +56,7 @@ module TestIRB script_lines[f.path] = code.split(/^/) workspace = eval(code, binding, f.path) - assert_equal(<<~EOS, workspace.code_around_binding) + assert_equal(<<~EOS, without_term { workspace.code_around_binding }) From: #{f.path} @ line 1 : @@ -90,5 +91,13 @@ module TestIRB const_set(:SCRIPT_LINES__, script_lines) if script_lines end end + + def without_term + env = ENV.to_h.dup + ENV.delete('TERM') + yield + ensure + ENV.replace(env) + end end end |