Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "message" to assert_screen #5

Merged
merged 2 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/yamatanooroti/vterm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,13 @@ def result
@result
end

def assert_screen(expected_lines)
def assert_screen(expected_lines, message = nil)
actual_lines = result
case expected_lines
when Array
assert_equal(expected_lines, actual_lines)
assert_equal(expected_lines, actual_lines, message)
when String
assert_equal(expected_lines, actual_lines.join("\n").sub(/\n*\z/, "\n"))
assert_equal(expected_lines, actual_lines.join("\n").sub(/\n*\z/, "\n"), message)
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions lib/yamatanooroti/windows.rb
Original file line number Diff line number Diff line change
Expand Up @@ -519,12 +519,12 @@ def result
@result
end

def assert_screen(expected_lines)
def assert_screen(expected_lines, message = nil)
case expected_lines
when Array
assert_equal(expected_lines, @result)
assert_equal(expected_lines, @result, message)
when String
assert_equal(expected_lines, @result.join("\n").sub(/\n*\z/, "\n"))
assert_equal(expected_lines, @result.join("\n").sub(/\n*\z/, "\n"), message)
end
end

Expand Down
10 changes: 10 additions & 0 deletions test/yamatanooroti/test_run_ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ def test_meta_key
get_out_from_tmpdir
end

def test_assert_screen_takes_a_message_when_failed
start_terminal(5, 30, ['ruby', '-e', 'puts "aaa"'])
close
assert_raise_with_message Test::Unit::AssertionFailedError, /\Amessage when failed/ do
assert_screen(<<~EOC, 'message when failed')
bbb
EOC
end
end

private

def get_into_tmpdir
Expand Down