|
|
d6a62f3 |
From 79953c476c51ab407ab3e75b12e5f3d63b6a0a61 Mon Sep 17 00:00:00 2001
|
|
|
d6a62f3 |
From: John Hawthorn <john@hawthorn.email>
|
|
|
d6a62f3 |
Date: Wed, 14 Aug 2019 10:39:55 -0700
|
|
|
d6a62f3 |
Subject: [PATCH] Allow tests to run without a TTY
|
|
|
d6a62f3 |
|
|
|
d6a62f3 |
We had two tests which assigned IO.console.winsize (to ensure output was
|
|
|
d6a62f3 |
consistent), however it's possible for IO.console to be nil.
|
|
|
d6a62f3 |
|
|
|
d6a62f3 |
This commit makes these tests stub IO.console_size directly (the method
|
|
|
d6a62f3 |
we actually call, we shouldn't have been relying on that calling
|
|
|
d6a62f3 |
IO.console.winsize anyways) or passes the width when initializing the
|
|
|
d6a62f3 |
class.
|
|
|
d6a62f3 |
|
|
|
d6a62f3 |
This allows tests to run without a TTY. This can be tested with ex.
|
|
|
d6a62f3 |
|
|
|
d6a62f3 |
ssh localhost "cd src/rails/actionpack && bundle exec rake"
|
|
|
d6a62f3 |
|
|
|
d6a62f3 |
or
|
|
|
d6a62f3 |
|
|
|
d6a62f3 |
(setsid bundle exec rake)
|
|
|
d6a62f3 |
---
|
|
|
d6a62f3 |
actionpack/lib/action_dispatch/routing/inspector.rb | 11 ++++++-----
|
|
|
d6a62f3 |
|
|
|
d6a62f3 |
diff --git a/actionpack/lib/action_dispatch/routing/inspector.rb b/actionpack/lib/action_dispatch/routing/inspector.rb
|
|
|
d6a62f3 |
index bf286c299dba..e60f43ed2dbb 100644
|
|
|
d6a62f3 |
--- a/actionpack/lib/action_dispatch/routing/inspector.rb
|
|
|
d6a62f3 |
+++ b/actionpack/lib/action_dispatch/routing/inspector.rb
|
|
|
d6a62f3 |
@@ -200,6 +200,11 @@ def widths(routes)
|
|
|
d6a62f3 |
end
|
|
|
d6a62f3 |
|
|
|
d6a62f3 |
class Expanded < Base
|
|
|
d6a62f3 |
+ def initialize(width: IO.console_size.second)
|
|
|
d6a62f3 |
+ @width = width
|
|
|
d6a62f3 |
+ super()
|
|
|
d6a62f3 |
+ end
|
|
|
d6a62f3 |
+
|
|
|
d6a62f3 |
def section_title(title)
|
|
|
d6a62f3 |
@buffer << "\n#{"[ #{title} ]"}"
|
|
|
d6a62f3 |
end
|
|
|
d6a62f3 |
@@ -222,11 +227,7 @@ def draw_expanded_section(routes)
|
|
|
d6a62f3 |
end
|
|
|
d6a62f3 |
|
|
|
d6a62f3 |
def route_header(index:)
|
|
|
d6a62f3 |
- console_width = IO.console_size.second
|
|
|
d6a62f3 |
- header_prefix = "--[ Route #{index} ]"
|
|
|
d6a62f3 |
- dash_remainder = [console_width - header_prefix.size, 0].max
|
|
|
d6a62f3 |
-
|
|
|
d6a62f3 |
- "#{header_prefix}#{'-' * dash_remainder}"
|
|
|
d6a62f3 |
+ "--[ Route #{index} ]".ljust(@width, "-")
|
|
|
d6a62f3 |
end
|
|
|
d6a62f3 |
end
|
|
|
d6a62f3 |
end
|