11# frozen_string_literal: false
2- require "irb"
3- require "fileutils"
4- require "tmpdir"
5-
6- require_relative "helper"
2+ require_relative "history_test_case"
73
84module TestIRB
9- class HistoryWindowsTest < TestCase
5+ class HistoryWindowsTest < HistoryTestCase
106 class TestInputMethodWithHistory < TestInputMethod
117 HISTORY = [ ]
128
@@ -19,42 +15,27 @@ def gets
1915 end
2016 end
2117
22- def setup
23- @conf_backup = IRB . conf . dup
24- @original_verbose , $VERBOSE = $VERBOSE, nil
25- IRB . instance_variable_set ( :@existing_rc_name_generators , nil )
26- end
27-
28- def teardown
29- IRB . conf . replace ( @conf_backup )
30- IRB . instance_variable_set ( :@existing_rc_name_generators , nil )
31- TestInputMethodWithHistory ::HISTORY . clear
32- $VERBOSE = @original_verbose
33- end
34-
3518 def test_history_is_saved_in_readonly_attributed_directory
3619 omit "Windows-only" unless windows?
3720
38- Dir . mktmpdir ( "test_irb_history_windows_" ) do |tmpdir |
39- history_dir = File . join ( tmpdir , "history" )
40- history_file = File . join ( history_dir , "irb_history" )
41- FileUtils . mkdir_p ( history_dir )
42-
43- with_readonly_attribute ( history_dir ) do
44- assert_nothing_raised do
45- File . write ( File . join ( history_dir , "manual_write" ) , "ok" )
46- end
21+ history_dir = File . join ( @tmpdir , "history" )
22+ history_file = File . join ( history_dir , "irb_history" )
23+ FileUtils . mkdir_p ( history_dir )
4724
48- _output , warning = capture_output do
49- run_irb_with_history ( history_file )
50- end
25+ with_readonly_attribute ( history_dir ) do
26+ assert_nothing_raised do
27+ File . write ( File . join ( history_dir , "manual_write" ) , "ok" )
28+ end
5129
52- assert_equal ( "" , warning )
53- assert_equal ( <<~HISTORY , File . read ( history_file ) )
54- puts 'history_entry'
55- exit
56- HISTORY
30+ _output , warning = capture_output do
31+ run_irb_with_history ( history_file )
5732 end
33+
34+ assert_equal ( "" , warning )
35+ assert_equal ( <<~HISTORY , File . read ( history_file ) )
36+ puts 'history_entry'
37+ exit
38+ HISTORY
5839 end
5940 end
6041
0 commit comments