aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/dispatch/routing
diff options
context:
space:
mode:
authorbogdanvlviv <bogdanvlviv@gmail.com>2018-03-05 20:21:27 +0200
committerbogdanvlviv <bogdanvlviv@gmail.com>2018-03-13 11:58:52 +0200
commit304906f1bd4cd6f2831b6ae39a9ae54599d85569 (patch)
treee3c42dac0b1677b5aa88eaa733ff2d6b38bccf7b /actionpack/test/dispatch/routing
parente78b1e5e615978a221b68530641101451ab83e68 (diff)
downloadrails-304906f1bd4cd6f2831b6ae39a9ae54599d85569.tar.gz
rails-304906f1bd4cd6f2831b6ae39a9ae54599d85569.tar.bz2
rails-304906f1bd4cd6f2831b6ae39a9ae54599d85569.zip
Introduce `ActionDispatch::Routing::ConsoleFormatter::Base`
- Create `Base` and inherit `Sheet` and `Expanded` in order to - prevent code duplication. - Remove trailing "\n" for components of `Expanded`. - There is no need for `Expanded#header` to return `@buffer` so return `nil` instead. - Change `no_routes` message "No routes were found for this controller" since if use `-g`, it sounds incorrect. - Display `No routes were found for this controller.` if apply `-c`. - Display `No routes were found for this grep pattern.` if apply `-g`. Related to #32130
Diffstat (limited to 'actionpack/test/dispatch/routing')
-rw-r--r--actionpack/test/dispatch/routing/inspector_test.rb22
1 files changed, 11 insertions, 11 deletions
diff --git a/actionpack/test/dispatch/routing/inspector_test.rb b/actionpack/test/dispatch/routing/inspector_test.rb
index 43407724aa..cf26f9fb3e 100644
--- a/actionpack/test/dispatch/routing/inspector_test.rb
+++ b/actionpack/test/dispatch/routing/inspector_test.rb
@@ -20,7 +20,7 @@ module ActionDispatch
@set = ActionDispatch::Routing::RouteSet.new
end
- def draw(options = nil, formater = ActionDispatch::Routing::ConsoleFormatter::Sheet.new, &block)
+ def draw(options = {}, formater = ActionDispatch::Routing::ConsoleFormatter::Sheet.new, &block)
@set.draw(&block)
inspector = ActionDispatch::Routing::RoutesInspector.new(@set.routes)
inspector.format(formater, options).split("\n")
@@ -306,7 +306,7 @@ module ActionDispatch
end
def test_routes_can_be_filtered
- output = draw("posts") do
+ output = draw(grep_pattern: "posts") do
resources :articles
resources :posts
end
@@ -335,7 +335,7 @@ module ActionDispatch
get "/cart", to: "cart#show"
end
- output = draw(nil, ActionDispatch::Routing::ConsoleFormatter::Expanded.new) do
+ output = draw({}, ActionDispatch::Routing::ConsoleFormatter::Expanded.new) do
get "/custom/assets", to: "custom_assets#show"
get "/custom/furnitures", to: "custom_furnitures#show"
mount engine => "/blog", :as => "blog"
@@ -368,18 +368,18 @@ module ActionDispatch
end
def test_no_routes_matched_filter_when_expanded
- output = draw("rails/dummy", ActionDispatch::Routing::ConsoleFormatter::Expanded.new) do
+ output = draw({ grep_pattern: "rails/dummy" }, ActionDispatch::Routing::ConsoleFormatter::Expanded.new) do
get "photos/:id" => "photos#show", :id => /[A-Z]\d{5}/
end
assert_equal [
- "No routes were found for this controller",
+ "No routes were found for this grep pattern.",
"For more information about routes, see the Rails guide: http://guides.rubyonrails.org/routing.html."
], output
end
def test_not_routes_when_expanded
- output = draw("rails/dummy", ActionDispatch::Routing::ConsoleFormatter::Expanded.new) {}
+ output = draw({ grep_pattern: "rails/dummy" }, ActionDispatch::Routing::ConsoleFormatter::Expanded.new) {}
assert_equal [
"You don't have any routes defined!",
@@ -391,7 +391,7 @@ module ActionDispatch
end
def test_routes_can_be_filtered_with_namespaced_controllers
- output = draw("admin/posts") do
+ output = draw(grep_pattern: "admin/posts") do
resources :articles
namespace :admin do
resources :posts
@@ -439,24 +439,24 @@ module ActionDispatch
end
assert_equal [
- "No routes were found for this controller",
+ "No routes were found for this controller.",
"For more information about routes, see the Rails guide: http://guides.rubyonrails.org/routing.html."
], output
end
def test_no_routes_matched_filter
- output = draw("rails/dummy") do
+ output = draw(grep_pattern: "rails/dummy") do
get "photos/:id" => "photos#show", :id => /[A-Z]\d{5}/
end
assert_equal [
- "No routes were found for this controller",
+ "No routes were found for this grep pattern.",
"For more information about routes, see the Rails guide: http://guides.rubyonrails.org/routing.html."
], output
end
def test_no_routes_were_defined
- output = draw("Rails::DummyController") {}
+ output = draw(grep_pattern: "Rails::DummyController") {}
assert_equal [
"You don't have any routes defined!",