10
10
module TestIRB
11
11
class HistoryTest < TestCase
12
12
def setup
13
+ @conf_backup = IRB . conf . dup
13
14
@original_verbose , $VERBOSE = $VERBOSE, nil
14
15
@tmpdir = Dir . mktmpdir ( "test_irb_history_" )
15
16
setup_envs ( home : @tmpdir )
16
- @backup_default_external = Encoding . default_external
17
+ IRB . conf [ :LC_MESSAGES ] = IRB ::Locale . new
18
+ save_encodings
17
19
IRB . instance_variable_set ( :@existing_rc_name_generators , nil )
18
20
end
19
21
20
22
def teardown
23
+ IRB . conf . replace ( @conf_backup )
21
24
IRB . instance_variable_set ( :@existing_rc_name_generators , nil )
22
25
teardown_envs
23
- Encoding . default_external = @backup_default_external
26
+ restore_encodings
24
27
$VERBOSE = @original_verbose
25
28
FileUtils . rm_rf ( @tmpdir )
26
29
end
@@ -146,7 +149,6 @@ def test_history_concurrent_use_readline
146
149
end
147
150
148
151
def test_history_concurrent_use_not_present
149
- IRB . conf [ :LC_MESSAGES ] = IRB ::Locale . new
150
152
IRB . conf [ :SAVE_HISTORY ] = 1
151
153
io = TestInputMethodWithRelineHistory . new
152
154
io . class ::HISTORY . clear
@@ -163,9 +165,9 @@ def test_history_concurrent_use_not_present
163
165
164
166
def test_history_different_encodings
165
167
IRB . conf [ :SAVE_HISTORY ] = 2
166
- Encoding . default_external = Encoding :: US_ASCII
167
- locale = IRB :: Locale . new ( "en_US.ASCII" )
168
- assert_history ( <<~EXPECTED_HISTORY . encode ( Encoding ::US_ASCII ) , <<~INITIAL_HISTORY . encode ( Encoding ::UTF_8 ) , <<~INPUT , locale : locale )
168
+ IRB . conf [ :LC_MESSAGES ] = IRB :: Locale . new ( "en_US.ASCII" )
169
+ IRB . __send__ ( :set_encoding , Encoding :: US_ASCII . name , override : false )
170
+ assert_history ( <<~EXPECTED_HISTORY . encode ( Encoding ::US_ASCII ) , <<~INITIAL_HISTORY . encode ( Encoding ::UTF_8 ) , <<~INPUT )
169
171
????
170
172
exit
171
173
EXPECTED_HISTORY
@@ -234,8 +236,7 @@ def history_concurrent_use_for_input_method(input_method)
234
236
end
235
237
end
236
238
237
- def assert_history ( expected_history , initial_irb_history , input , input_method = TestInputMethodWithRelineHistory , locale : IRB ::Locale . new )
238
- IRB . conf [ :LC_MESSAGES ] = locale
239
+ def assert_history ( expected_history , initial_irb_history , input , input_method = TestInputMethodWithRelineHistory )
239
240
actual_history = nil
240
241
history_file = IRB . rc_file ( "_history" )
241
242
ENV [ "HOME" ] = @tmpdir
0 commit comments