Skip to content

Commit

Permalink
Update test helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
st0012 committed Jul 5, 2023
1 parent 7ceae36 commit 1911b73
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions test/reline/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,19 @@
module Reline
class <<self
def test_mode(ansi: false)
config = send(:core).config
remove_const('IOGate') if const_defined?('IOGate')
const_set('IOGate', ansi ? Reline::ANSI : Reline::GeneralIO)
io_gate = ansi ? Reline::ANSI : Reline::GeneralIO
const_set('IOGate', io_gate)
config.io_gate = io_gate
if ENV['RELINE_TEST_ENCODING']
encoding = Encoding.find(ENV['RELINE_TEST_ENCODING'])
else
encoding = Encoding::UTF_8
end
Reline::GeneralIO.reset(encoding: encoding) unless ansi
send(:core).config.instance_variable_set(:@test_mode, true)
send(:core).config.reset
io_gate.reset(encoding: encoding) unless ansi
config.instance_variable_set(:@test_mode, true)
config.reset
end

def test_reset
Expand Down

0 comments on commit 1911b73

Please sign in to comment.