summaryrefslogtreecommitdiff
path: root/test/irb/test_init.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/irb/test_init.rb')
-rw-r--r--test/irb/test_init.rb40
1 files changed, 40 insertions, 0 deletions
diff --git a/test/irb/test_init.rb b/test/irb/test_init.rb
index b6a8f5529b..7d11b5b507 100644
--- a/test/irb/test_init.rb
+++ b/test/irb/test_init.rb
@@ -218,4 +218,44 @@ module TestIRB
ARGV.replace(orig)
end
end
+
+ class InitIntegrationTest < IntegrationTestCase
+ def test_load_error_in_rc_file_is_warned
+ write_rc <<~'IRBRC'
+ require "file_that_does_not_exist"
+ IRBRC
+
+ write_ruby <<~'RUBY'
+ binding.irb
+ RUBY
+
+ output = run_ruby_file do
+ type "'foobar'"
+ type "exit"
+ end
+
+ # IRB session should still be started
+ assert_includes output, "foobar"
+ assert_includes output, 'cannot load such file -- file_that_does_not_exist (LoadError)'
+ end
+
+ def test_normal_errors_in_rc_file_is_warned
+ write_rc <<~'IRBRC'
+ raise "I'm an error"
+ IRBRC
+
+ write_ruby <<~'RUBY'
+ binding.irb
+ RUBY
+
+ output = run_ruby_file do
+ type "'foobar'"
+ type "exit"
+ end
+
+ # IRB session should still be started
+ assert_includes output, "foobar"
+ assert_includes output, 'I\'m an error (RuntimeError)'
+ end
+ end
end