diff options
author | bogdanvlviv <bogdanvlviv@gmail.com> | 2018-03-03 15:50:01 +0200 |
---|---|---|
committer | bogdanvlviv <bogdanvlviv@gmail.com> | 2018-03-05 14:56:59 +0200 |
commit | 012a4a3842db66b5fc6b190cb61d4d845d1cd527 (patch) | |
tree | 83173fb82595ba340bea4a378741713acfd2e145 /actionpack/test | |
parent | ae2d36cf21281f4b720332a086b021d867e80084 (diff) | |
download | rails-012a4a3842db66b5fc6b190cb61d4d845d1cd527.tar.gz rails-012a4a3842db66b5fc6b190cb61d4d845d1cd527.tar.bz2 rails-012a4a3842db66b5fc6b190cb61d4d845d1cd527.zip |
Draw line of a route name to the end of row console on `rails routes --expanded`
In order to get width of console use `IO::console_size`,
See https://ruby-doc.org/stdlib-2.4.1/libdoc/io/console/rdoc/IO.html#method-c-console_size
Related to #32130
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/dispatch/routing/inspector_test.rb | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/actionpack/test/dispatch/routing/inspector_test.rb b/actionpack/test/dispatch/routing/inspector_test.rb index 127212b228..43407724aa 100644 --- a/actionpack/test/dispatch/routing/inspector_test.rb +++ b/actionpack/test/dispatch/routing/inspector_test.rb @@ -3,6 +3,7 @@ require "abstract_unit" require "rails/engine" require "action_dispatch/routing/inspector" +require "io/console/size" class MountedRackApp def self.call(env) @@ -322,6 +323,9 @@ module ActionDispatch end def test_routes_when_expanded + previous_console_winsize = IO.console.winsize + IO.console.winsize = [0, 23] + engine = Class.new(Rails::Engine) do def self.inspect "Blog::Engine" @@ -337,31 +341,32 @@ module ActionDispatch mount engine => "/blog", :as => "blog" end - assert_equal ["--[ Route 1 ]------------------------------------------------------------", + assert_equal ["--[ Route 1 ]----------", "Prefix | custom_assets", "Verb | GET", "URI | /custom/assets(.:format)", "Controller#Action | custom_assets#show", - "--[ Route 2 ]------------------------------------------------------------", + "--[ Route 2 ]----------", "Prefix | custom_furnitures", "Verb | GET", "URI | /custom/furnitures(.:format)", "Controller#Action | custom_furnitures#show", - "--[ Route 3 ]------------------------------------------------------------", + "--[ Route 3 ]----------", "Prefix | blog", "Verb | ", "URI | /blog", "Controller#Action | Blog::Engine", "", "[ Routes for Blog::Engine ]", - "--[ Route 1 ]------------------------------------------------------------", + "--[ Route 1 ]----------", "Prefix | cart", "Verb | GET", "URI | /cart(.:format)", "Controller#Action | cart#show"], output + ensure + IO.console.winsize = previous_console_winsize end - def test_no_routes_matched_filter_when_expanded output = draw("rails/dummy", ActionDispatch::Routing::ConsoleFormatter::Expanded.new) do get "photos/:id" => "photos#show", :id => /[A-Z]\d{5}/ |