From 76b620b341b54eb80028f03cc828333defacc87e Mon Sep 17 00:00:00 2001 From: Stan Lo Date: Sat, 11 Jan 2025 22:03:54 +0800 Subject: [ruby/irb] `IRB.conf[:SAVE_HISTORY]` should handle boolean values (https://github.com/ruby/irb/pull/1062) Although not documented, `IRB.conf[:SAVE_HISTORY]` used to accept boolean, which now causes `NoMethodError` when used. This commit changes the behavior to accept boolean values and adds tests for the behavior. https://github.com/ruby/irb/commit/8b1a07b2a8 --- test/irb/test_history.rb | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'test') diff --git a/test/irb/test_history.rb b/test/irb/test_history.rb index 021bb682c1..0171bb0eca 100644 --- a/test/irb/test_history.rb +++ b/test/irb/test_history.rb @@ -279,6 +279,47 @@ module TestIRB end class IRBHistoryIntegrationTest < IntegrationTestCase + def test_history_saving_can_be_disabled_with_false + write_history "" + write_rc <<~RUBY + IRB.conf[:SAVE_HISTORY] = false + RUBY + + write_ruby <<~'RUBY' + binding.irb + RUBY + + output = run_ruby_file do + type "puts 'foo' + 'bar'" + type "exit" + end + + assert_include(output, "foobar") + assert_equal "", @history_file.open.read + end + + def test_history_saving_accepts_true + write_history "" + write_rc <<~RUBY + IRB.conf[:SAVE_HISTORY] = true + RUBY + + write_ruby <<~'RUBY' + binding.irb + RUBY + + output = run_ruby_file do + type "puts 'foo' + 'bar'" + type "exit" + end + + assert_include(output, "foobar") + assert_equal <<~HISTORY, @history_file.open.read + puts 'foo' + 'bar' + exit + HISTORY + end + def test_history_saving_with_debug write_history "" -- cgit v1.2.3