Skip to content

Commit

Permalink
Use IRB's own doc for doc dialog tests (#743)
Browse files Browse the repository at this point in the history
* Use IRB's own doc for doc dialog tests

* Run doc dialog tests for older Rubies too

* Remove unnecessary CI setups
  • Loading branch information
st0012 authored Oct 30, 2023
1 parent dfa527a commit 97a2b86
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ jobs:
- name: Install dependencies
run: |
gem install bundler --no-document
gem install rake
gem rdoc --all --ri --no-rdoc
WITH_VTERM=1 bundle install
- name: rake test_yamatanooroti
run: WITH_VTERM=1 bundle exec rake test_yamatanooroti
36 changes: 20 additions & 16 deletions test/irb/yamatanooroti/test_rendering.rb
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,10 @@ def test_symbol_with_backtick
end

def test_autocomplete_with_showdoc_in_gaps_on_narrow_screen_right
omit if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3.1')
write_irbrc <<~'LINES'
rdoc_dir = File.join(@tmpdir, 'rdoc')
system("bundle exec rdoc -r -o #{rdoc_dir}")
write_irbrc <<~LINES
IRB.conf[:EXTRA_DOC_DIRS] = ['#{rdoc_dir}']
IRB.conf[:PROMPT][:MY_PROMPT] = {
:PROMPT_I => "%03n> ",
:PROMPT_S => "%03n> ",
Expand All @@ -214,32 +216,34 @@ def test_autocomplete_with_showdoc_in_gaps_on_narrow_screen_right
IRB.conf[:PROMPT_MODE] = :MY_PROMPT
puts 'start IRB'
LINES
start_terminal(4, 19, %W{ruby -I/home/aycabta/ruby/reline/lib -I#{@pwd}/lib #{@pwd}/exe/irb}, startup_message: 'start IRB')
write("Str\C-i")
start_terminal(4, 19, %W{ruby -I#{@pwd}/lib #{@pwd}/exe/irb}, startup_message: 'start IRB')
write("IR\C-i")
close

# This is because on macOS we display different shortcut for displaying the full doc
# 'O' is for 'Option' and 'A' is for 'Alt'
if RUBY_PLATFORM =~ /darwin/
assert_screen(<<~EOC)
start IRB
001> String
StringPress O
StructString
001> IRB
IRBPress Opti
IRB
EOC
else
assert_screen(<<~EOC)
start IRB
001> String
StringPress A
StructString
001> IRB
IRBPress Alt+
IRB
EOC
end
end

def test_autocomplete_with_showdoc_in_gaps_on_narrow_screen_left
omit if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3.1')
write_irbrc <<~'LINES'
rdoc_dir = File.join(@tmpdir, 'rdoc')
system("bundle exec rdoc -r -o #{rdoc_dir}")
write_irbrc <<~LINES
IRB.conf[:EXTRA_DOC_DIRS] = ['#{rdoc_dir}']
IRB.conf[:PROMPT][:MY_PROMPT] = {
:PROMPT_I => "%03n> ",
:PROMPT_S => "%03n> ",
Expand All @@ -249,13 +253,13 @@ def test_autocomplete_with_showdoc_in_gaps_on_narrow_screen_left
puts 'start IRB'
LINES
start_terminal(4, 12, %W{ruby -I#{@pwd}/lib #{@pwd}/exe/irb}, startup_message: 'start IRB')
write("Str\C-i")
write("IR\C-i")
close
assert_screen(<<~EOC)
start IRB
001> String
PressString
StrinStruct
001> IRB
PressIRB
IRB
EOC
end

Expand Down

0 comments on commit 97a2b86

Please sign in to comment.