Skip to content

Commit

Permalink
Use teardown to close in test, Don't use startup in README example
Browse files Browse the repository at this point in the history
  • Loading branch information
tompng committed Sep 30, 2024
1 parent 516bc48 commit 2060325
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 15 deletions.
10 changes: 2 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,8 @@ You can test the executed result and its rendering on the automatically detected
require 'yamatanooroti'

class MyTest < Yamatanooroti::TestCase
def setup
start_terminal(5, 30, ['irb', '-f', '--multiline'])
end

def test_example
start_terminal(5, 30, ['irb', '-f', '--multiline'])
write(":a\n")
assert_screen(['irb(main):001:0> :a', '=> :a', 'irb(main):002:0>', '', ''])
close
Expand Down Expand Up @@ -57,11 +54,8 @@ If you want to specify vterm environment that needs vterm gem, you can use `Yama
require 'yamatanooroti'

class MyTest < Yamatanooroti::VTermTestCase
def setup
start_terminal(5, 30, ['irb', '-f', '--multiline'])
end

def test_example
start_terminal(5, 30, ['irb', '-f', '--multiline'])
write(":a\n")
assert_screen(['irb(main):001:0> :a', '=> :a', 'irb(main):002:0>', '', ''])
close
Expand Down
11 changes: 4 additions & 7 deletions test/yamatanooroti/test_multiplatform.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ def setup
start_terminal(5, 30, ['ruby', 'bin/simple_repl'], startup_message: 'prompt>')
end

def teardown
close
end

def test_example
write(":a\n")
assert_screen(['prompt> :a', '=> :a', 'prompt>', '', ''])
Expand All @@ -13,7 +17,6 @@ def test_example
=> :a
prompt>
EOC
close
end

def test_result_repeatedly
Expand All @@ -23,22 +26,19 @@ def test_result_repeatedly
write(":b\n")
assert_screen(/=> :b\nprompt>/)
assert_equal(['prompt> :a', '=> :a', 'prompt> :b', '=> :b', 'prompt>'], result)
close
end

def test_assert_screen_retries
write("sleep 1\n")
assert_screen(/=> 1\nprompt>/)
assert_equal(['prompt> sleep 1', '=> 1', 'prompt>', '', ''], result)
close
end

def test_assert_screen_timeout
write("sleep 3\n")
assert_raise do
assert_screen(/=> 3\nprompt>/)
end
close
end

def test_auto_wrap
Expand All @@ -50,20 +50,17 @@ def test_auto_wrap
=> 12345678901234567890123
prompt>
EOC
close
end

def test_fullwidth
write(":あ\n")
assert_screen(/=> :あ\nprompt>/)
assert_equal(['prompt> :あ', '=> :あ', 'prompt>', '', ''], result)
close
end

def test_two_fullwidth
write(":あい\n")
assert_screen(/=> :あい\nprompt>/)
assert_equal(['prompt> :あい', '=> :あい', 'prompt>', '', ''], result)
close
end
end

0 comments on commit 2060325

Please sign in to comment.