Skip to content

Commit f16f067

Browse files
committed
Add rdbgrc file test
1 parent acd4f12 commit f16f067

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

test/debug/rdbg_option_test.rb

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,49 @@ def test_debugger_stops_immediately
5656
end
5757
end
5858

59+
class RCFileTest < TestCase
60+
def rc_script
61+
"config set skip_path /foo/bar/"
62+
end
63+
64+
def program
65+
<<~RUBY
66+
1| a = 1
67+
RUBY
68+
end
69+
70+
def with_rc_script
71+
rc_filename = "~/.rdbgrc"
72+
renamed_rc_filename = "~/.rdbgrc.original"
73+
File.rename(rc_filename, renamed_rc_filename) if File.exist?(rc_filename)
74+
File.open(File.join(Dir.home, ".rdbgrc"), "w") { |f| f.write(rc_script) }
75+
76+
yield
77+
ensure
78+
File.rename(renamed_rc_filename, rc_filename) if File.exist?(renamed_rc_filename)
79+
end
80+
81+
def test_debugger_loads_the_rc_file_by_default
82+
with_rc_script do
83+
run_rdbg(program) do
84+
type "config skip_path"
85+
assert_line_text(/foo\\\/bar/)
86+
type "c"
87+
end
88+
end
89+
end
90+
91+
def test_debugger_doesnt_load_the_rc_file_with_no_rc
92+
with_rc_script do
93+
run_rdbg(program, options: "--no-rc") do
94+
type "config skip_path"
95+
assert_no_line_text(/foo\\\/bar/)
96+
type "c"
97+
end
98+
end
99+
end
100+
end
101+
59102
class InitScriptTest < TestCase
60103
TEMPFILE_BASENAME = __FILE__.hash.abs.to_s(16)
61104

0 commit comments

Comments
 (0)