diff options
author | Xavier Noria <fxn@hashref.com> | 2016-08-06 18:54:50 +0200 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2016-08-06 18:54:50 +0200 |
commit | 35b3de8021e68649cac963bd82a74cc75d1f60f0 (patch) | |
tree | d37f9096be6ee54a13d3c04cc8e1c5a9ba0d99ec /actionpack/test/journey | |
parent | 628e51ff109334223094e30ad1365188bbd7f9c6 (diff) | |
download | rails-35b3de8021e68649cac963bd82a74cc75d1f60f0.tar.gz rails-35b3de8021e68649cac963bd82a74cc75d1f60f0.tar.bz2 rails-35b3de8021e68649cac963bd82a74cc75d1f60f0.zip |
applies new string literal convention in actionpack/test
The current code base is not uniform. After some discussion,
we have chosen to go with double quotes by default.
Diffstat (limited to 'actionpack/test/journey')
-rw-r--r-- | actionpack/test/journey/gtg/builder_test.rb | 26 | ||||
-rw-r--r-- | actionpack/test/journey/gtg/transition_table_test.rb | 38 | ||||
-rw-r--r-- | actionpack/test/journey/nfa/simulator_test.rb | 52 | ||||
-rw-r--r-- | actionpack/test/journey/nfa/transition_table_test.rb | 40 | ||||
-rw-r--r-- | actionpack/test/journey/nodes/symbol_test.rb | 2 | ||||
-rw-r--r-- | actionpack/test/journey/path/pattern_test.rb | 164 | ||||
-rw-r--r-- | actionpack/test/journey/route/definition/parser_test.rb | 58 | ||||
-rw-r--r-- | actionpack/test/journey/route/definition/scanner_test.rb | 74 | ||||
-rw-r--r-- | actionpack/test/journey/route_test.rb | 62 | ||||
-rw-r--r-- | actionpack/test/journey/router/utils_test.rb | 2 | ||||
-rw-r--r-- | actionpack/test/journey/router_test.rb | 170 | ||||
-rw-r--r-- | actionpack/test/journey/routes_test.rb | 20 |
12 files changed, 354 insertions, 354 deletions
diff --git a/actionpack/test/journey/gtg/builder_test.rb b/actionpack/test/journey/gtg/builder_test.rb index c1da374007..270bc7d741 100644 --- a/actionpack/test/journey/gtg/builder_test.rb +++ b/actionpack/test/journey/gtg/builder_test.rb @@ -1,28 +1,28 @@ -require 'abstract_unit' +require "abstract_unit" module ActionDispatch module Journey module GTG class TestBuilder < ActiveSupport::TestCase def test_following_states_multi - table = tt ['a|a'] - assert_equal 1, table.move([0], 'a').length + table = tt ["a|a"] + assert_equal 1, table.move([0], "a").length end def test_following_states_multi_regexp - table = tt [':a|b'] - assert_equal 1, table.move([0], 'fooo').length - assert_equal 2, table.move([0], 'b').length + table = tt [":a|b"] + assert_equal 1, table.move([0], "fooo").length + assert_equal 2, table.move([0], "b").length end def test_multi_path - table = tt ['/:a/d', '/b/c'] + table = tt ["/:a/d", "/b/c"] [ - [1, '/'], - [2, 'b'], - [2, '/'], - [1, 'c'], + [1, "/"], + [2, "b"], + [2, "/"], + [1, "c"], ].inject([0]) { |state, (exp, sym)| new = table.move(state, sym) assert_equal exp, new.length @@ -40,7 +40,7 @@ module ActionDispatch sim = NFA::Simulator.new table - match = sim.match '/articles/new' + match = sim.match "/articles/new" assert_equal 2, match.memos.length end @@ -54,7 +54,7 @@ module ActionDispatch sim = NFA::Simulator.new table - match = sim.match '/articles/new' + match = sim.match "/articles/new" assert_equal 2, match.memos.length end diff --git a/actionpack/test/journey/gtg/transition_table_test.rb b/actionpack/test/journey/gtg/transition_table_test.rb index b968780d8d..00be1c2da6 100644 --- a/actionpack/test/journey/gtg/transition_table_test.rb +++ b/actionpack/test/journey/gtg/transition_table_test.rb @@ -1,5 +1,5 @@ -require 'abstract_unit' -require 'active_support/json/decoding' +require "abstract_unit" +require "active_support/json/decoding" module ActionDispatch module Journey @@ -14,9 +14,9 @@ module ActionDispatch } json = ActiveSupport::JSON.decode table.to_json - assert json['regexp_states'] - assert json['string_states'] - assert json['accepting'] + assert json["regexp_states"] + assert json["string_states"] + assert json["accepting"] end if system("dot -V 2>/dev/null") @@ -34,26 +34,26 @@ module ActionDispatch end def test_simulate_gt - sim = simulator_for ['/foo', '/bar'] - assert_match sim, '/foo' + sim = simulator_for ["/foo", "/bar"] + assert_match sim, "/foo" end def test_simulate_gt_regexp - sim = simulator_for [':foo'] - assert_match sim, 'foo' + sim = simulator_for [":foo"] + assert_match sim, "foo" end def test_simulate_gt_regexp_mix - sim = simulator_for ['/get', '/:method/foo'] - assert_match sim, '/get' - assert_match sim, '/get/foo' + sim = simulator_for ["/get", "/:method/foo"] + assert_match sim, "/get" + assert_match sim, "/get/foo" end def test_simulate_optional - sim = simulator_for ['/foo(/bar)'] - assert_match sim, '/foo' - assert_match sim, '/foo/bar' - assert_no_match sim, '/foo/' + sim = simulator_for ["/foo(/bar)"] + assert_match sim, "/foo" + assert_match sim, "/foo/bar" + assert_no_match sim, "/foo/" end def test_match_data @@ -65,10 +65,10 @@ module ActionDispatch sim = GTG::Simulator.new tt - match = sim.match '/get' + match = sim.match "/get" assert_equal [paths.first], match.memos - match = sim.match '/get/foo' + match = sim.match "/get/foo" assert_equal [paths.last], match.memos end @@ -86,7 +86,7 @@ module ActionDispatch builder = GTG::Builder.new ast sim = GTG::Simulator.new builder.transition_table - match = sim.match '/articles/new' + match = sim.match "/articles/new" assert_equal [paths[1], paths[3]], match.memos end diff --git a/actionpack/test/journey/nfa/simulator_test.rb b/actionpack/test/journey/nfa/simulator_test.rb index 673a491fe5..117208c4a4 100644 --- a/actionpack/test/journey/nfa/simulator_test.rb +++ b/actionpack/test/journey/nfa/simulator_test.rb @@ -1,47 +1,47 @@ -require 'abstract_unit' +require "abstract_unit" module ActionDispatch module Journey module NFA class TestSimulator < ActiveSupport::TestCase def test_simulate_simple - sim = simulator_for ['/foo'] - assert_match sim, '/foo' + sim = simulator_for ["/foo"] + assert_match sim, "/foo" end def test_simulate_simple_no_match - sim = simulator_for ['/foo'] - assert_no_match sim, 'foo' + sim = simulator_for ["/foo"] + assert_no_match sim, "foo" end def test_simulate_simple_no_match_too_long - sim = simulator_for ['/foo'] - assert_no_match sim, '/foo/bar' + sim = simulator_for ["/foo"] + assert_no_match sim, "/foo/bar" end def test_simulate_simple_no_match_wrong_string - sim = simulator_for ['/foo'] - assert_no_match sim, '/bar' + sim = simulator_for ["/foo"] + assert_no_match sim, "/bar" end def test_simulate_regex - sim = simulator_for ['/:foo/bar'] - assert_match sim, '/bar/bar' - assert_match sim, '/foo/bar' + sim = simulator_for ["/:foo/bar"] + assert_match sim, "/bar/bar" + assert_match sim, "/foo/bar" end def test_simulate_or - sim = simulator_for ['/foo', '/bar'] - assert_match sim, '/bar' - assert_match sim, '/foo' - assert_no_match sim, '/baz' + sim = simulator_for ["/foo", "/bar"] + assert_match sim, "/bar" + assert_match sim, "/foo" + assert_no_match sim, "/baz" end def test_simulate_optional - sim = simulator_for ['/foo(/bar)'] - assert_match sim, '/foo' - assert_match sim, '/foo/bar' - assert_no_match sim, '/foo/' + sim = simulator_for ["/foo(/bar)"] + assert_match sim, "/foo" + assert_match sim, "/foo/bar" + assert_no_match sim, "/foo/" end def test_matchdata_has_memos @@ -59,17 +59,17 @@ module ActionDispatch sim = Simulator.new builder.transition_table - md = sim.match '/foo' + md = sim.match "/foo" assert_equal [expected], md.memos end def test_matchdata_memos_on_merge parser = Journey::Parser.new routes = [ - '/articles(.:format)', - '/articles/new(.:format)', - '/articles/:id/edit(.:format)', - '/articles/:id(.:format)', + "/articles(.:format)", + "/articles/new(.:format)", + "/articles/:id/edit(.:format)", + "/articles/:id(.:format)", ].map { |path| ast = parser.parse path ast.each { |n| n.memo = ast } @@ -82,7 +82,7 @@ module ActionDispatch nfa = Journey::NFA::Builder.new ast sim = Simulator.new nfa.transition_table - md = sim.match '/articles' + md = sim.match "/articles" assert_equal [asts.first], md.memos end diff --git a/actionpack/test/journey/nfa/transition_table_test.rb b/actionpack/test/journey/nfa/transition_table_test.rb index 1248082c03..81f9501688 100644 --- a/actionpack/test/journey/nfa/transition_table_test.rb +++ b/actionpack/test/journey/nfa/transition_table_test.rb @@ -1,4 +1,4 @@ -require 'abstract_unit' +require "abstract_unit" module ActionDispatch module Journey @@ -9,55 +9,55 @@ module ActionDispatch end def test_eclosure - table = tt '/' + table = tt "/" assert_equal [0], table.eclosure(0) - table = tt ':a|:b' + table = tt ":a|:b" assert_equal 3, table.eclosure(0).length - table = tt '(:a|:b)' + table = tt "(:a|:b)" assert_equal 5, table.eclosure(0).length assert_equal 5, table.eclosure([0]).length end def test_following_states_one - table = tt '/' + table = tt "/" - assert_equal [1], table.following_states(0, '/') - assert_equal [1], table.following_states([0], '/') + assert_equal [1], table.following_states(0, "/") + assert_equal [1], table.following_states([0], "/") end def test_following_states_group - table = tt 'a|b' + table = tt "a|b" states = table.eclosure 0 - assert_equal 1, table.following_states(states, 'a').length - assert_equal 1, table.following_states(states, 'b').length + assert_equal 1, table.following_states(states, "a").length + assert_equal 1, table.following_states(states, "b").length end def test_following_states_multi - table = tt 'a|a' + table = tt "a|a" states = table.eclosure 0 - assert_equal 2, table.following_states(states, 'a').length - assert_equal 0, table.following_states(states, 'b').length + assert_equal 2, table.following_states(states, "a").length + assert_equal 0, table.following_states(states, "b").length end def test_following_states_regexp - table = tt 'a|:a' + table = tt "a|:a" states = table.eclosure 0 - assert_equal 1, table.following_states(states, 'a').length + assert_equal 1, table.following_states(states, "a").length assert_equal 1, table.following_states(states, /[^\.\/\?]+/).length - assert_equal 0, table.following_states(states, 'b').length + assert_equal 0, table.following_states(states, "b").length end def test_alphabet - table = tt 'a|:a' - assert_equal [/[^\.\/\?]+/, 'a'], table.alphabet + table = tt "a|:a" + assert_equal [/[^\.\/\?]+/, "a"], table.alphabet - table = tt 'a|a' - assert_equal ['a'], table.alphabet + table = tt "a|a" + assert_equal ["a"], table.alphabet end private diff --git a/actionpack/test/journey/nodes/symbol_test.rb b/actionpack/test/journey/nodes/symbol_test.rb index adf85b860c..baf60f40b8 100644 --- a/actionpack/test/journey/nodes/symbol_test.rb +++ b/actionpack/test/journey/nodes/symbol_test.rb @@ -1,4 +1,4 @@ -require 'abstract_unit' +require "abstract_unit" module ActionDispatch module Journey diff --git a/actionpack/test/journey/path/pattern_test.rb b/actionpack/test/journey/path/pattern_test.rb index 72858f5eda..7b013cbbc6 100644 --- a/actionpack/test/journey/path/pattern_test.rb +++ b/actionpack/test/journey/path/pattern_test.rb @@ -1,4 +1,4 @@ -require 'abstract_unit' +require "abstract_unit" module ActionDispatch module Journey @@ -8,17 +8,17 @@ module ActionDispatch x = /.+/ { - '/:controller(/:action)' => %r{\A/(#{x})(?:/([^/.?]+))?\Z}, - '/:controller/foo' => %r{\A/(#{x})/foo\Z}, - '/:controller/:action' => %r{\A/(#{x})/([^/.?]+)\Z}, - '/:controller' => %r{\A/(#{x})\Z}, - '/:controller(/:action(/:id))' => %r{\A/(#{x})(?:/([^/.?]+)(?:/([^/.?]+))?)?\Z}, - '/:controller/:action.xml' => %r{\A/(#{x})/([^/.?]+)\.xml\Z}, - '/:controller.:format' => %r{\A/(#{x})\.([^/.?]+)\Z}, - '/:controller(.:format)' => %r{\A/(#{x})(?:\.([^/.?]+))?\Z}, - '/:controller/*foo' => %r{\A/(#{x})/(.+)\Z}, - '/:controller/*foo/bar' => %r{\A/(#{x})/(.+)/bar\Z}, - '/:foo|*bar' => %r{\A/(?:([^/.?]+)|(.+))\Z}, + "/:controller(/:action)" => %r{\A/(#{x})(?:/([^/.?]+))?\Z}, + "/:controller/foo" => %r{\A/(#{x})/foo\Z}, + "/:controller/:action" => %r{\A/(#{x})/([^/.?]+)\Z}, + "/:controller" => %r{\A/(#{x})\Z}, + "/:controller(/:action(/:id))" => %r{\A/(#{x})(?:/([^/.?]+)(?:/([^/.?]+))?)?\Z}, + "/:controller/:action.xml" => %r{\A/(#{x})/([^/.?]+)\.xml\Z}, + "/:controller.:format" => %r{\A/(#{x})\.([^/.?]+)\Z}, + "/:controller(.:format)" => %r{\A/(#{x})(?:\.([^/.?]+))?\Z}, + "/:controller/*foo" => %r{\A/(#{x})/(.+)\Z}, + "/:controller/*foo/bar" => %r{\A/(#{x})/(.+)/bar\Z}, + "/:foo|*bar" => %r{\A/(?:([^/.?]+)|(.+))\Z}, }.each do |path, expected| define_method(:"test_to_regexp_#{path}") do path = Pattern.build( @@ -32,17 +32,17 @@ module ActionDispatch end { - '/:controller(/:action)' => %r{\A/(#{x})(?:/([^/.?]+))?}, - '/:controller/foo' => %r{\A/(#{x})/foo}, - '/:controller/:action' => %r{\A/(#{x})/([^/.?]+)}, - '/:controller' => %r{\A/(#{x})}, - '/:controller(/:action(/:id))' => %r{\A/(#{x})(?:/([^/.?]+)(?:/([^/.?]+))?)?}, - '/:controller/:action.xml' => %r{\A/(#{x})/([^/.?]+)\.xml}, - '/:controller.:format' => %r{\A/(#{x})\.([^/.?]+)}, - '/:controller(.:format)' => %r{\A/(#{x})(?:\.([^/.?]+))?}, - '/:controller/*foo' => %r{\A/(#{x})/(.+)}, - '/:controller/*foo/bar' => %r{\A/(#{x})/(.+)/bar}, - '/:foo|*bar' => %r{\A/(?:([^/.?]+)|(.+))}, + "/:controller(/:action)" => %r{\A/(#{x})(?:/([^/.?]+))?}, + "/:controller/foo" => %r{\A/(#{x})/foo}, + "/:controller/:action" => %r{\A/(#{x})/([^/.?]+)}, + "/:controller" => %r{\A/(#{x})}, + "/:controller(/:action(/:id))" => %r{\A/(#{x})(?:/([^/.?]+)(?:/([^/.?]+))?)?}, + "/:controller/:action.xml" => %r{\A/(#{x})/([^/.?]+)\.xml}, + "/:controller.:format" => %r{\A/(#{x})\.([^/.?]+)}, + "/:controller(.:format)" => %r{\A/(#{x})(?:\.([^/.?]+))?}, + "/:controller/*foo" => %r{\A/(#{x})/(.+)}, + "/:controller/*foo/bar" => %r{\A/(#{x})/(.+)/bar}, + "/:foo|*bar" => %r{\A/(?:([^/.?]+)|(.+))}, }.each do |path, expected| define_method(:"test_to_non_anchored_regexp_#{path}") do path = Pattern.build( @@ -56,16 +56,16 @@ module ActionDispatch end { - '/:controller(/:action)' => %w{ controller action }, - '/:controller/foo' => %w{ controller }, - '/:controller/:action' => %w{ controller action }, - '/:controller' => %w{ controller }, - '/:controller(/:action(/:id))' => %w{ controller action id }, - '/:controller/:action.xml' => %w{ controller action }, - '/:controller.:format' => %w{ controller format }, - '/:controller(.:format)' => %w{ controller format }, - '/:controller/*foo' => %w{ controller foo }, - '/:controller/*foo/bar' => %w{ controller foo }, + "/:controller(/:action)" => %w{ controller action }, + "/:controller/foo" => %w{ controller }, + "/:controller/:action" => %w{ controller action }, + "/:controller" => %w{ controller }, + "/:controller(/:action(/:id))" => %w{ controller action id }, + "/:controller/:action.xml" => %w{ controller action }, + "/:controller.:format" => %w{ controller format }, + "/:controller(.:format)" => %w{ controller format }, + "/:controller/*foo" => %w{ controller foo }, + "/:controller/*foo/bar" => %w{ controller foo }, }.each do |path, expected| define_method(:"test_names_#{path}") do path = Pattern.build( @@ -80,7 +80,7 @@ module ActionDispatch def test_to_regexp_with_extended_group path = Pattern.build( - '/page/:name', + "/page/:name", { :name => / #ROFL (tender|love @@ -89,16 +89,16 @@ module ActionDispatch SEPARATORS, true ) - assert_match(path, '/page/tender') - assert_match(path, '/page/love') - assert_no_match(path, '/page/loving') + assert_match(path, "/page/tender") + assert_match(path, "/page/love") + assert_no_match(path, "/page/loving") end def test_optional_names [ - ['/:foo(/:bar(/:baz))', %w{ bar baz }], - ['/:foo(/:bar)', %w{ bar }], - ['/:foo(/:bar)/:lol(/:baz)', %w{ bar baz }], + ["/:foo(/:bar(/:baz))", %w{ bar baz }], + ["/:foo(/:bar)", %w{ bar }], + ["/:foo(/:bar)/:lol(/:baz)", %w{ bar baz }], ].each do |pattern, list| path = Pattern.from_string pattern assert_equal list.sort, path.optional_names.sort @@ -107,31 +107,31 @@ module ActionDispatch def test_to_regexp_match_non_optional path = Pattern.build( - '/:name', + "/:name", { :name => /\d+/ }, SEPARATORS, true ) - assert_match(path, '/123') - assert_no_match(path, '/') + assert_match(path, "/123") + assert_no_match(path, "/") end def test_to_regexp_with_group path = Pattern.build( - '/page/:name', + "/page/:name", { :name => /(tender|love)/ }, SEPARATORS, true ) - assert_match(path, '/page/tender') - assert_match(path, '/page/love') - assert_no_match(path, '/page/loving') + assert_match(path, "/page/tender") + assert_match(path, "/page/love") + assert_no_match(path, "/page/loving") end def test_ast_sets_regular_expressions requirements = { :name => /(tender|love)/, :value => /./ } path = Pattern.build( - '/page/:name/:value', + "/page/:name/:value", requirements, SEPARATORS, true @@ -146,26 +146,26 @@ module ActionDispatch def test_match_data_with_group path = Pattern.build( - '/page/:name', + "/page/:name", { :name => /(tender|love)/ }, SEPARATORS, true ) - match = path.match '/page/tender' - assert_equal 'tender', match[1] + match = path.match "/page/tender" + assert_equal "tender", match[1] assert_equal 2, match.length end def test_match_data_with_multi_group path = Pattern.build( - '/page/:name/:id', + "/page/:name/:id", { :name => /t(((ender|love)))()/ }, SEPARATORS, true ) - match = path.match '/page/tender/10' - assert_equal 'tender', match[1] - assert_equal '10', match[2] + match = path.match "/page/tender/10" + assert_equal "tender", match[1] + assert_equal "10", match[2] assert_equal 3, match.length assert_equal %w{ tender 10 }, match.captures end @@ -173,7 +173,7 @@ module ActionDispatch def test_star_with_custom_re z = /\d+/ path = Pattern.build( - '/page/*foo', + "/page/*foo", { :foo => z }, SEPARATORS, true @@ -183,76 +183,76 @@ module ActionDispatch def test_insensitive_regexp_with_group path = Pattern.build( - '/page/:name/aaron', + "/page/:name/aaron", { :name => /(tender|love)/i }, SEPARATORS, true ) - assert_match(path, '/page/TENDER/aaron') - assert_match(path, '/page/loVE/aaron') - assert_no_match(path, '/page/loVE/AAron') + assert_match(path, "/page/TENDER/aaron") + assert_match(path, "/page/loVE/aaron") + assert_no_match(path, "/page/loVE/AAron") end def test_to_regexp_with_strexp - path = Pattern.build('/:controller', { }, SEPARATORS, true) + path = Pattern.build("/:controller", { }, SEPARATORS, true) x = %r{\A/([^/.?]+)\Z} assert_equal(x.source, path.source) end def test_to_regexp_defaults - path = Pattern.from_string '/:controller(/:action(/:id))' + path = Pattern.from_string "/:controller(/:action(/:id))" expected = %r{\A/([^/.?]+)(?:/([^/.?]+)(?:/([^/.?]+))?)?\Z} assert_equal expected, path.to_regexp end def test_failed_match - path = Pattern.from_string '/:controller(/:action(/:id(.:format)))' - uri = 'content' + path = Pattern.from_string "/:controller(/:action(/:id(.:format)))" + uri = "content" assert_not path =~ uri end def test_match_controller - path = Pattern.from_string '/:controller(/:action(/:id(.:format)))' - uri = '/content' + path = Pattern.from_string "/:controller(/:action(/:id(.:format)))" + uri = "/content" match = path =~ uri assert_equal %w{ controller action id format }, match.names - assert_equal 'content', match[1] + assert_equal "content", match[1] assert_nil match[2] assert_nil match[3] assert_nil match[4] end def test_match_controller_action - path = Pattern.from_string '/:controller(/:action(/:id(.:format)))' - uri = '/content/list' + path = Pattern.from_string "/:controller(/:action(/:id(.:format)))" + uri = "/content/list" match = path =~ uri assert_equal %w{ controller action id format }, match.names - assert_equal 'content', match[1] - assert_equal 'list', match[2] + assert_equal "content", match[1] + assert_equal "list", match[2] assert_nil match[3] assert_nil match[4] end def test_match_controller_action_id - path = Pattern.from_string '/:controller(/:action(/:id(.:format)))' - uri = '/content/list/10' + path = Pattern.from_string "/:controller(/:action(/:id(.:format)))" + uri = "/content/list/10" match = path =~ uri assert_equal %w{ controller action id format }, match.names - assert_equal 'content', match[1] - assert_equal 'list', match[2] - assert_equal '10', match[3] + assert_equal "content", match[1] + assert_equal "list", match[2] + assert_equal "10", match[3] assert_nil match[4] end def test_match_literal path = Path::Pattern.from_string "/books(/:action(.:format))" - uri = '/books' + uri = "/books" match = path =~ uri assert_equal %w{ action format }, match.names assert_nil match[1] @@ -262,21 +262,21 @@ module ActionDispatch def test_match_literal_with_action path = Path::Pattern.from_string "/books(/:action(.:format))" - uri = '/books/list' + uri = "/books/list" match = path =~ uri assert_equal %w{ action format }, match.names - assert_equal 'list', match[1] + assert_equal "list", match[1] assert_nil match[2] end def test_match_literal_with_action_and_format path = Path::Pattern.from_string "/books(/:action(.:format))" - uri = '/books/list.rss' + uri = "/books/list.rss" match = path =~ uri assert_equal %w{ action format }, match.names - assert_equal 'list', match[1] - assert_equal 'rss', match[2] + assert_equal "list", match[1] + assert_equal "rss", match[2] end end end diff --git a/actionpack/test/journey/route/definition/parser_test.rb b/actionpack/test/journey/route/definition/parser_test.rb index d7d7172a40..8e00d8ab89 100644 --- a/actionpack/test/journey/route/definition/parser_test.rb +++ b/actionpack/test/journey/route/definition/parser_test.rb @@ -1,4 +1,4 @@ -require 'abstract_unit' +require "abstract_unit" module ActionDispatch module Journey @@ -9,88 +9,88 @@ module ActionDispatch end def test_slash - assert_equal :SLASH, @parser.parse('/').type - assert_round_trip '/' + assert_equal :SLASH, @parser.parse("/").type + assert_round_trip "/" end def test_segment - assert_round_trip '/foo' + assert_round_trip "/foo" end def test_segments - assert_round_trip '/foo/bar' + assert_round_trip "/foo/bar" end def test_segment_symbol - assert_round_trip '/foo/:id' + assert_round_trip "/foo/:id" end def test_symbol - assert_round_trip '/:foo' + assert_round_trip "/:foo" end def test_group - assert_round_trip '(/:foo)' + assert_round_trip "(/:foo)" end def test_groups - assert_round_trip '(/:foo)(/:bar)' + assert_round_trip "(/:foo)(/:bar)" end def test_nested_groups - assert_round_trip '(/:foo(/:bar))' + assert_round_trip "(/:foo(/:bar))" end def test_dot_symbol - assert_round_trip('.:format') + assert_round_trip(".:format") end def test_dot_literal - assert_round_trip('.xml') + assert_round_trip(".xml") end def test_segment_dot - assert_round_trip('/foo.:bar') + assert_round_trip("/foo.:bar") end def test_segment_group_dot - assert_round_trip('/foo(.:bar)') + assert_round_trip("/foo(.:bar)") end def test_segment_group - assert_round_trip('/foo(/:action)') + assert_round_trip("/foo(/:action)") end def test_segment_groups - assert_round_trip('/foo(/:action)(/:bar)') + assert_round_trip("/foo(/:action)(/:bar)") end def test_segment_nested_groups - assert_round_trip('/foo(/:action(/:bar))') + assert_round_trip("/foo(/:action(/:bar))") end def test_group_followed_by_path - assert_round_trip('/foo(/:action)/:bar') + assert_round_trip("/foo(/:action)/:bar") end def test_star - assert_round_trip('*foo') - assert_round_trip('/*foo') - assert_round_trip('/bar/*foo') - assert_round_trip('/bar/(*foo)') + assert_round_trip("*foo") + assert_round_trip("/*foo") + assert_round_trip("/bar/*foo") + assert_round_trip("/bar/(*foo)") end def test_or - assert_round_trip('a|b') - assert_round_trip('a|b|c') - assert_round_trip('(a|b)|c') - assert_round_trip('a|(b|c)') - assert_round_trip('*a|(b|c)') - assert_round_trip('*a|:b|c') + assert_round_trip("a|b") + assert_round_trip("a|b|c") + assert_round_trip("(a|b)|c") + assert_round_trip("a|(b|c)") + assert_round_trip("*a|(b|c)") + assert_round_trip("*a|:b|c") end def test_arbitrary - assert_round_trip('/bar/*foo#') + assert_round_trip("/bar/*foo#") end def test_literal_dot_paren diff --git a/actionpack/test/journey/route/definition/scanner_test.rb b/actionpack/test/journey/route/definition/scanner_test.rb index 7a510f1e07..82a50cf539 100644 --- a/actionpack/test/journey/route/definition/scanner_test.rb +++ b/actionpack/test/journey/route/definition/scanner_test.rb @@ -1,4 +1,4 @@ -require 'abstract_unit' +require "abstract_unit" module ActionDispatch module Journey @@ -11,44 +11,44 @@ module ActionDispatch # /page/:id(/:action)(.:format) def test_tokens [ - ['/', [[:SLASH, '/']]], - ['*omg', [[:STAR, '*omg']]], - ['/page', [[:SLASH, '/'], [:LITERAL, 'page']]], - ['/page!', [[:SLASH, '/'], [:LITERAL, 'page!']]], - ['/page$', [[:SLASH, '/'], [:LITERAL, 'page$']]], - ['/page&', [[:SLASH, '/'], [:LITERAL, 'page&']]], - ["/page'", [[:SLASH, '/'], [:LITERAL, "page'"]]], - ['/page*', [[:SLASH, '/'], [:LITERAL, 'page*']]], - ['/page+', [[:SLASH, '/'], [:LITERAL, 'page+']]], - ['/page,', [[:SLASH, '/'], [:LITERAL, 'page,']]], - ['/page;', [[:SLASH, '/'], [:LITERAL, 'page;']]], - ['/page=', [[:SLASH, '/'], [:LITERAL, 'page=']]], - ['/page@', [[:SLASH, '/'], [:LITERAL, 'page@']]], - ['/page\:', [[:SLASH, '/'], [:LITERAL, 'page:']]], - ['/page\(', [[:SLASH, '/'], [:LITERAL, 'page(']]], - ['/page\)', [[:SLASH, '/'], [:LITERAL, 'page)']]], - ['/~page', [[:SLASH, '/'], [:LITERAL, '~page']]], - ['/pa-ge', [[:SLASH, '/'], [:LITERAL, 'pa-ge']]], - ['/:page', [[:SLASH, '/'], [:SYMBOL, ':page']]], - ['/(:page)', [ - [:SLASH, '/'], - [:LPAREN, '('], - [:SYMBOL, ':page'], - [:RPAREN, ')'], + ["/", [[:SLASH, "/"]]], + ["*omg", [[:STAR, "*omg"]]], + ["/page", [[:SLASH, "/"], [:LITERAL, "page"]]], + ["/page!", [[:SLASH, "/"], [:LITERAL, "page!"]]], + ["/page$", [[:SLASH, "/"], [:LITERAL, "page$"]]], + ["/page&", [[:SLASH, "/"], [:LITERAL, "page&"]]], + ["/page'", [[:SLASH, "/"], [:LITERAL, "page'"]]], + ["/page*", [[:SLASH, "/"], [:LITERAL, "page*"]]], + ["/page+", [[:SLASH, "/"], [:LITERAL, "page+"]]], + ["/page,", [[:SLASH, "/"], [:LITERAL, "page,"]]], + ["/page;", [[:SLASH, "/"], [:LITERAL, "page;"]]], + ["/page=", [[:SLASH, "/"], [:LITERAL, "page="]]], + ["/page@", [[:SLASH, "/"], [:LITERAL, "page@"]]], + ['/page\:', [[:SLASH, "/"], [:LITERAL, "page:"]]], + ['/page\(', [[:SLASH, "/"], [:LITERAL, "page("]]], + ['/page\)', [[:SLASH, "/"], [:LITERAL, "page)"]]], + ["/~page", [[:SLASH, "/"], [:LITERAL, "~page"]]], + ["/pa-ge", [[:SLASH, "/"], [:LITERAL, "pa-ge"]]], + ["/:page", [[:SLASH, "/"], [:SYMBOL, ":page"]]], + ["/(:page)", [ + [:SLASH, "/"], + [:LPAREN, "("], + [:SYMBOL, ":page"], + [:RPAREN, ")"], ]], - ['(/:action)', [ - [:LPAREN, '('], - [:SLASH, '/'], - [:SYMBOL, ':action'], - [:RPAREN, ')'], + ["(/:action)", [ + [:LPAREN, "("], + [:SLASH, "/"], + [:SYMBOL, ":action"], + [:RPAREN, ")"], ]], - ['(())', [[:LPAREN, '('], - [:LPAREN, '('], [:RPAREN, ')'], [:RPAREN, ')']]], - ['(.:format)', [ - [:LPAREN, '('], - [:DOT, '.'], - [:SYMBOL, ':format'], - [:RPAREN, ')'], + ["(())", [[:LPAREN, "("], + [:LPAREN, "("], [:RPAREN, ")"], [:RPAREN, ")"]]], + ["(.:format)", [ + [:LPAREN, "("], + [:DOT, "."], + [:SYMBOL, ":format"], + [:RPAREN, ")"], ]], ].each do |str, expected| @scanner.scan_setup str diff --git a/actionpack/test/journey/route_test.rb b/actionpack/test/journey/route_test.rb index 22c3b8113d..7e03259827 100644 --- a/actionpack/test/journey/route_test.rb +++ b/actionpack/test/journey/route_test.rb @@ -1,11 +1,11 @@ -require 'abstract_unit' +require "abstract_unit" module ActionDispatch module Journey class TestRoute < ActiveSupport::TestCase def test_initialize app = Object.new - path = Path::Pattern.from_string '/:controller(/:action(/:id(.:format)))' + path = Path::Pattern.from_string "/:controller(/:action(/:id(.:format)))" defaults = {} route = Route.build("name", app, path, {}, [], defaults) @@ -16,7 +16,7 @@ module ActionDispatch def test_route_adds_itself_as_memo app = Object.new - path = Path::Pattern.from_string '/:controller(/:action(/:id(.:format)))' + path = Path::Pattern.from_string "/:controller(/:action(/:id(.:format)))" defaults = {} route = Route.build("name", app, path, {}, [], defaults) @@ -26,66 +26,66 @@ module ActionDispatch end def test_path_requirements_override_defaults - path = Path::Pattern.build(':name', { name: /love/ }, '/', true) - defaults = { name: 'tender' } - route = Route.build('name', nil, path, {}, [], defaults) + path = Path::Pattern.build(":name", { name: /love/ }, "/", true) + defaults = { name: "tender" } + route = Route.build("name", nil, path, {}, [], defaults) assert_equal(/love/, route.requirements[:name]) end def test_ip_address - path = Path::Pattern.from_string '/messages/:id(.:format)' - route = Route.build("name", nil, path, {:ip => '192.168.1.1'}, [], - { :controller => 'foo', :action => 'bar' }) - assert_equal '192.168.1.1', route.ip + path = Path::Pattern.from_string "/messages/:id(.:format)" + route = Route.build("name", nil, path, {:ip => "192.168.1.1"}, [], + { :controller => "foo", :action => "bar" }) + assert_equal "192.168.1.1", route.ip end def test_default_ip - path = Path::Pattern.from_string '/messages/:id(.:format)' + path = Path::Pattern.from_string "/messages/:id(.:format)" route = Route.build("name", nil, path, {}, [], - { :controller => 'foo', :action => 'bar' }) + { :controller => "foo", :action => "bar" }) assert_equal(//, route.ip) end def test_format_with_star - path = Path::Pattern.from_string '/:controller/*extra' + path = Path::Pattern.from_string "/:controller/*extra" route = Route.build("name", nil, path, {}, [], - { :controller => 'foo', :action => 'bar' }) - assert_equal '/foo/himom', route.format({ - :controller => 'foo', - :extra => 'himom', + { :controller => "foo", :action => "bar" }) + assert_equal "/foo/himom", route.format({ + :controller => "foo", + :extra => "himom", }) end def test_connects_all_match - path = Path::Pattern.from_string '/:controller(/:action(/:id(.:format)))' - route = Route.build("name", nil, path, {:action => 'bar'}, [], { :controller => 'foo' }) + path = Path::Pattern.from_string "/:controller(/:action(/:id(.:format)))" + route = Route.build("name", nil, path, {:action => "bar"}, [], { :controller => "foo" }) - assert_equal '/foo/bar/10', route.format({ - :controller => 'foo', - :action => 'bar', + assert_equal "/foo/bar/10", route.format({ + :controller => "foo", + :action => "bar", :id => 10 }) end def test_extras_are_not_included_if_optional - path = Path::Pattern.from_string '/page/:id(/:action)' - route = Route.build("name", nil, path, { }, [], { :action => 'show' }) + path = Path::Pattern.from_string "/page/:id(/:action)" + route = Route.build("name", nil, path, { }, [], { :action => "show" }) - assert_equal '/page/10', route.format({ :id => 10 }) + assert_equal "/page/10", route.format({ :id => 10 }) end def test_extras_are_not_included_if_optional_with_parameter - path = Path::Pattern.from_string '(/sections/:section)/pages/:id' - route = Route.build("name", nil, path, { }, [], { :action => 'show' }) + path = Path::Pattern.from_string "(/sections/:section)/pages/:id" + route = Route.build("name", nil, path, { }, [], { :action => "show" }) - assert_equal '/pages/10', route.format({:id => 10}) + assert_equal "/pages/10", route.format({:id => 10}) end def test_extras_are_not_included_if_optional_parameter_is_nil - path = Path::Pattern.from_string '(/sections/:section)/pages/:id' - route = Route.build("name", nil, path, { }, [], { :action => 'show' }) + path = Path::Pattern.from_string "(/sections/:section)/pages/:id" + route = Route.build("name", nil, path, { }, [], { :action => "show" }) - assert_equal '/pages/10', route.format({:id => 10, :section => nil}) + assert_equal "/pages/10", route.format({:id => 10, :section => nil}) end def test_score diff --git a/actionpack/test/journey/router/utils_test.rb b/actionpack/test/journey/router/utils_test.rb index 2b505f081e..b77bf6628a 100644 --- a/actionpack/test/journey/router/utils_test.rb +++ b/actionpack/test/journey/router/utils_test.rb @@ -1,4 +1,4 @@ -require 'abstract_unit' +require "abstract_unit" module ActionDispatch module Journey diff --git a/actionpack/test/journey/router_test.rb b/actionpack/test/journey/router_test.rb index 75caf56d32..fb595e8bea 100644 --- a/actionpack/test/journey/router_test.rb +++ b/actionpack/test/journey/router_test.rb @@ -1,4 +1,4 @@ -require 'abstract_unit' +require "abstract_unit" module ActionDispatch module Journey @@ -15,9 +15,9 @@ module ActionDispatch end def test_dashes - get '/foo-bar-baz', to: 'foo#bar' + get "/foo-bar-baz", to: "foo#bar" - env = rails_env 'PATH_INFO' => '/foo-bar-baz' + env = rails_env "PATH_INFO" => "/foo-bar-baz" called = false router.recognize(env) do |r, params| called = true @@ -26,10 +26,10 @@ module ActionDispatch end def test_unicode - get '/ほげ', to: 'foo#bar' + get "/ほげ", to: "foo#bar" #match the escaped version of /ほげ - env = rails_env 'PATH_INFO' => '/%E3%81%BB%E3%81%92' + env = rails_env "PATH_INFO" => "/%E3%81%BB%E3%81%92" called = false router.recognize(env) do |r, params| called = true @@ -41,7 +41,7 @@ module ActionDispatch get "/whois/:domain", :domain => /\w+\.[\w\.]+/, to: "foo#bar" get "/whois/:id(.:format)", to: "foo#baz" - env = rails_env 'PATH_INFO' => '/whois/example.com' + env = rails_env "PATH_INFO" => "/whois/example.com" list = [] router.recognize(env) do |r, params| @@ -51,39 +51,39 @@ module ActionDispatch r = list.first - assert_equal '/whois/:domain(.:format)', r.path.spec.to_s + assert_equal "/whois/:domain(.:format)", r.path.spec.to_s end def test_required_parts_verified_are_anchored get "/foo/:id", :id => /\d/, anchor: false, to: "foo#bar" assert_raises(ActionController::UrlGenerationError) do - @formatter.generate(nil, { :controller => "foo", :action => "bar", :id => '10' }, { }) + @formatter.generate(nil, { :controller => "foo", :action => "bar", :id => "10" }, { }) end end def test_required_parts_are_verified_when_building get "/foo/:id", :id => /\d+/, anchor: false, to: "foo#bar" - path, _ = @formatter.generate(nil, { :controller => "foo", :action => "bar", :id => '10' }, { }) - assert_equal '/foo/10', path + path, _ = @formatter.generate(nil, { :controller => "foo", :action => "bar", :id => "10" }, { }) + assert_equal "/foo/10", path assert_raises(ActionController::UrlGenerationError) do - @formatter.generate(nil, { :id => 'aa' }, { }) + @formatter.generate(nil, { :id => "aa" }, { }) end end def test_only_required_parts_are_verified get "/foo(/:id)", :id => /\d/, :to => "foo#bar" - path, _ = @formatter.generate(nil, { :controller => "foo", :action => "bar", :id => '10' }, { }) - assert_equal '/foo/10', path + path, _ = @formatter.generate(nil, { :controller => "foo", :action => "bar", :id => "10" }, { }) + assert_equal "/foo/10", path path, _ = @formatter.generate(nil, { :controller => "foo", :action => "bar" }, { }) - assert_equal '/foo', path + assert_equal "/foo", path - path, _ = @formatter.generate(nil, { :controller => "foo", :action => "bar", :id => 'aa' }, { }) - assert_equal '/foo/aa', path + path, _ = @formatter.generate(nil, { :controller => "foo", :action => "bar", :id => "aa" }, { }) + assert_equal "/foo/aa", path end def test_knows_what_parts_are_missing_from_named_route @@ -109,31 +109,31 @@ module ActionDispatch def test_X_Cascade get "/messages(.:format)", to: "foo#bar" - resp = router.serve(rails_env({ 'REQUEST_METHOD' => 'GET', 'PATH_INFO' => '/lol' })) - assert_equal ['Not Found'], resp.last - assert_equal 'pass', resp[1]['X-Cascade'] + resp = router.serve(rails_env({ "REQUEST_METHOD" => "GET", "PATH_INFO" => "/lol" })) + assert_equal ["Not Found"], resp.last + assert_equal "pass", resp[1]["X-Cascade"] assert_equal 404, resp.first end def test_clear_trailing_slash_from_script_name_on_root_unanchored_routes - app = lambda { |env| [200, {}, ['success!']] } - get '/weblog', :to => app + app = lambda { |env| [200, {}, ["success!"]] } + get "/weblog", :to => app - env = rack_env('SCRIPT_NAME' => '', 'PATH_INFO' => '/weblog') + env = rack_env("SCRIPT_NAME" => "", "PATH_INFO" => "/weblog") resp = route_set.call env - assert_equal ['success!'], resp.last - assert_equal '', env['SCRIPT_NAME'] + assert_equal ["success!"], resp.last + assert_equal "", env["SCRIPT_NAME"] end def test_defaults_merge_correctly - get '/foo(/:id)', to: "foo#bar", id: nil + get "/foo(/:id)", to: "foo#bar", id: nil - env = rails_env 'PATH_INFO' => '/foo/10' + env = rails_env "PATH_INFO" => "/foo/10" router.recognize(env) do |r, params| - assert_equal({:id => '10', :controller => "foo", :action => "bar"}, params) + assert_equal({:id => "10", :controller => "foo", :action => "bar"}, params) end - env = rails_env 'PATH_INFO' => '/foo' + env = rails_env "PATH_INFO" => "/foo" router.recognize(env) do |r, params| assert_equal({:id => nil, :controller => "foo", :action => "bar"}, params) end @@ -142,25 +142,25 @@ module ActionDispatch def test_recognize_with_unbound_regexp get "/foo", anchor: false, to: "foo#bar" - env = rails_env 'PATH_INFO' => '/foo/bar' + env = rails_env "PATH_INFO" => "/foo/bar" router.recognize(env) { |*_| } - assert_equal '/foo', env.env['SCRIPT_NAME'] - assert_equal '/bar', env.env['PATH_INFO'] + assert_equal "/foo", env.env["SCRIPT_NAME"] + assert_equal "/bar", env.env["PATH_INFO"] end def test_bound_regexp_keeps_path_info get "/foo", to: "foo#bar" - env = rails_env 'PATH_INFO' => '/foo' + env = rails_env "PATH_INFO" => "/foo" - before = env.env['SCRIPT_NAME'] + before = env.env["SCRIPT_NAME"] router.recognize(env) { |*_| } - assert_equal before, env.env['SCRIPT_NAME'] - assert_equal '/foo', env.env['PATH_INFO'] + assert_equal before, env.env["SCRIPT_NAME"] + assert_equal "/foo", env.env["PATH_INFO"] end def test_path_not_found @@ -172,7 +172,7 @@ module ActionDispatch ].each do |path| get path, to: "foo#bar" end - env = rails_env 'PATH_INFO' => '/messages/unknown/path' + env = rails_env "PATH_INFO" => "/messages/unknown/path" yielded = false router.recognize(env) do |*whatever| @@ -184,22 +184,22 @@ module ActionDispatch def test_required_part_in_recall get "/messages/:a/:b", to: "foo#bar" - path, _ = @formatter.generate(nil, { :controller => "foo", :action => "bar", :a => 'a' }, { :b => 'b' }) + path, _ = @formatter.generate(nil, { :controller => "foo", :action => "bar", :a => "a" }, { :b => "b" }) assert_equal "/messages/a/b", path end def test_splat_in_recall get "/*path", to: "foo#bar" - path, _ = @formatter.generate(nil, { :controller => "foo", :action => "bar" }, { :path => 'b' }) + path, _ = @formatter.generate(nil, { :controller => "foo", :action => "bar" }, { :path => "b" }) assert_equal "/b", path end def test_recall_should_be_used_when_scoring - get "/messages/:action(/:id(.:format))", to: 'foo#bar' - get "/messages/:id(.:format)", to: 'bar#baz' + get "/messages/:action(/:id(.:format))", to: "foo#bar" + get "/messages/:id(.:format)", to: "bar#baz" - path, _ = @formatter.generate(nil, { :controller => "foo", :id => 10 }, { :action => 'index' }) + path, _ = @formatter.generate(nil, { :controller => "foo", :id => 10 }, { :action => "index" }) assert_equal "/messages/index/10", path end @@ -207,10 +207,10 @@ module ActionDispatch get "/:controller(/:action(.:format))", to: "tasks#lol" params = { :controller => "tasks", :format => nil } - extras = { :action => 'lol' } + extras = { :action => "lol" } path, _ = @formatter.generate(nil, params, extras) - assert_equal '/tasks', path + assert_equal "/tasks", path end def test_generate_slash @@ -219,11 +219,11 @@ module ActionDispatch get "/", Hash[params] path, _ = @formatter.generate(nil, Hash[params], {}) - assert_equal '/', path + assert_equal "/", path end def test_generate_calls_param_proc - get '/:controller(/:action)', to: "foo#bar" + get "/:controller(/:action)", to: "foo#bar" parameterized = [] params = [ [:controller, "tasks"], @@ -239,36 +239,36 @@ module ActionDispatch end def test_generate_id - get '/:controller(/:action)', to: 'foo#bar' + get "/:controller(/:action)", to: "foo#bar" path, params = @formatter.generate( nil, {:id=>1, :controller=>"tasks", :action=>"show"}, {}) - assert_equal '/tasks/show', path + assert_equal "/tasks/show", path assert_equal({:id => 1}, params) end def test_generate_escapes - get '/:controller(/:action)', to: "foo#bar" + get "/:controller(/:action)", to: "foo#bar" path, _ = @formatter.generate(nil, { :controller => "tasks", :action => "a/b c+d", }, {}) - assert_equal '/tasks/a%2Fb%20c+d', path + assert_equal "/tasks/a%2Fb%20c+d", path end def test_generate_escapes_with_namespaced_controller - get '/:controller(/:action)', to: "foo#bar" + get "/:controller(/:action)", to: "foo#bar" path, _ = @formatter.generate( nil, { :controller => "admin/tasks", :action => "a/b c+d", }, {}) - assert_equal '/admin/tasks/a%2Fb%20c+d', path + assert_equal "/admin/tasks/a%2Fb%20c+d", path end def test_generate_extra_params - get '/:controller(/:action)', to: "foo#bar" + get "/:controller(/:action)", to: "foo#bar" path, params = @formatter.generate( nil, { :id => 1, @@ -276,12 +276,12 @@ module ActionDispatch :action => "show", :relative_url_root => nil }, {}) - assert_equal '/tasks/show', path + assert_equal "/tasks/show", path assert_equal({:id => 1, :relative_url_root => nil}, params) end def test_generate_missing_keys_no_matches_different_format_keys - get '/:controller/:action/:name', to: "foo#bar" + get "/:controller/:action/:name", to: "foo#bar" primarty_parameters = { :id => 1, :controller => "tasks", @@ -289,9 +289,9 @@ module ActionDispatch :relative_url_root => nil } redirection_parameters = { - 'action'=>'show', + "action"=>"show", } - missing_key = 'name' + missing_key = "name" missing_parameters ={ missing_key => "task_1" } @@ -307,37 +307,37 @@ module ActionDispatch end def test_generate_uses_recall_if_needed - get '/:controller(/:action(/:id))', to: "foo#bar" + get "/:controller(/:action(/:id))", to: "foo#bar" path, params = @formatter.generate( nil, {:controller =>"tasks", :id => 10}, {:action =>"index"}) - assert_equal '/tasks/index/10', path + assert_equal "/tasks/index/10", path assert_equal({}, params) end def test_generate_with_name - get '/:controller(/:action)', to: 'foo#bar', as: 'tasks' + get "/:controller(/:action)", to: "foo#bar", as: "tasks" path, params = @formatter.generate( "tasks", {:controller=>"tasks"}, {:controller=>"tasks", :action=>"index"}) - assert_equal '/tasks', path + assert_equal "/tasks", path assert_equal({}, params) end { - '/content' => { :controller => 'content' }, - '/content/list' => { :controller => 'content', :action => 'list' }, - '/content/show/10' => { :controller => 'content', :action => 'show', :id => "10" }, + "/content" => { :controller => "content" }, + "/content/list" => { :controller => "content", :action => "list" }, + "/content/show/10" => { :controller => "content", :action => "show", :id => "10" }, }.each do |request_path, expected| define_method("test_recognize_#{expected.keys.map(&:to_s).join('_')}") do - get "/:controller(/:action(/:id))", to: 'foo#bar' + get "/:controller(/:action(/:id))", to: "foo#bar" route = @routes.first - env = rails_env 'PATH_INFO' => request_path + env = rails_env "PATH_INFO" => request_path called = false router.recognize(env) do |r, params| @@ -351,13 +351,13 @@ module ActionDispatch end { - :segment => ['/a%2Fb%20c+d/splat', { :segment => 'a/b c+d', :splat => 'splat' }], - :splat => ['/segment/a/b%20c+d', { :segment => 'segment', :splat => 'a/b c+d' }] + :segment => ["/a%2Fb%20c+d/splat", { :segment => "a/b c+d", :splat => "splat" }], + :splat => ["/segment/a/b%20c+d", { :segment => "segment", :splat => "a/b c+d" }] }.each do |name, (request_path, expected)| define_method("test_recognize_#{name}") do - get '/:segment/*splat', to: 'foo#bar' + get "/:segment/*splat", to: "foo#bar" - env = rails_env 'PATH_INFO' => request_path + env = rails_env "PATH_INFO" => request_path called = false route = @routes.first @@ -375,12 +375,12 @@ module ActionDispatch get "/:controller(/:action(/:id))", { :controller => /.+?/ } route = @routes.first - env = rails_env 'PATH_INFO' => '/admin/users/show/10' + env = rails_env "PATH_INFO" => "/admin/users/show/10" called = false expected = { - :controller => 'admin/users', - :action => 'show', - :id => '10' + :controller => "admin/users", + :action => "show", + :id => "10" } router.recognize(env) do |r, params| @@ -395,8 +395,8 @@ module ActionDispatch get "/books(/:action(.:format))", controller: "books" route = @routes.first - env = rails_env 'PATH_INFO' => '/books/list.rss' - expected = { :controller => 'books', :action => 'list', :format => 'rss' } + env = rails_env "PATH_INFO" => "/books/list.rss" + expected = { :controller => "books", :action => "list", :format => "rss" } called = false router.recognize(env) do |r, params| assert_equal route, r @@ -408,11 +408,11 @@ module ActionDispatch end def test_recognize_head_route - match "/books(/:action(.:format))", via: 'head', to: 'foo#bar' + match "/books(/:action(.:format))", via: "head", to: "foo#bar" env = rails_env( - 'PATH_INFO' => '/books/list.rss', - 'REQUEST_METHOD' => 'HEAD' + "PATH_INFO" => "/books/list.rss", + "REQUEST_METHOD" => "HEAD" ) called = false @@ -424,9 +424,9 @@ module ActionDispatch end def test_recognize_head_request_as_get_route - get "/books(/:action(.:format))", to: 'foo#bar' + get "/books(/:action(.:format))", to: "foo#bar" - env = rails_env 'PATH_INFO' => '/books/list.rss', + env = rails_env "PATH_INFO" => "/books/list.rss", "REQUEST_METHOD" => "HEAD" called = false @@ -440,7 +440,7 @@ module ActionDispatch def test_recognize_cares_about_get_verbs match "/books(/:action(.:format))", to: "foo#bar", via: :get - env = rails_env 'PATH_INFO' => '/books/list.rss', + env = rails_env "PATH_INFO" => "/books/list.rss", "REQUEST_METHOD" => "POST" called = false @@ -454,7 +454,7 @@ module ActionDispatch def test_recognize_cares_about_post_verbs match "/books(/:action(.:format))", to: "foo#bar", via: :post - env = rails_env 'PATH_INFO' => '/books/list.rss', + env = rails_env "PATH_INFO" => "/books/list.rss", "REQUEST_METHOD" => "POST" called = false @@ -469,7 +469,7 @@ module ActionDispatch match "/books(/:action(.:format))", to: "foo#bar", via: [:post, :get] %w( POST GET ).each do |verb| - env = rails_env 'PATH_INFO' => '/books/list.rss', + env = rails_env "PATH_INFO" => "/books/list.rss", "REQUEST_METHOD" => verb called = false @@ -480,8 +480,8 @@ module ActionDispatch assert called end - env = rails_env 'PATH_INFO' => '/books/list.rss', - "REQUEST_METHOD" => 'PUT' + env = rails_env "PATH_INFO" => "/books/list.rss", + "REQUEST_METHOD" => "PUT" called = false router.recognize(env) do |r, params| diff --git a/actionpack/test/journey/routes_test.rb b/actionpack/test/journey/routes_test.rb index f8293dfc5f..ca735ea022 100644 --- a/actionpack/test/journey/routes_test.rb +++ b/actionpack/test/journey/routes_test.rb @@ -1,4 +1,4 @@ -require 'abstract_unit' +require "abstract_unit" module ActionDispatch module Journey @@ -14,7 +14,7 @@ module ActionDispatch end def test_clear - mapper.get "/foo(/:id)", to: "foo#bar", as: 'aaron' + mapper.get "/foo(/:id)", to: "foo#bar", as: "aaron" assert_not_predicate routes, :empty? assert_equal 1, routes.length @@ -24,35 +24,35 @@ module ActionDispatch end def test_ast - mapper.get "/foo(/:id)", to: "foo#bar", as: 'aaron' + mapper.get "/foo(/:id)", to: "foo#bar", as: "aaron" ast = routes.ast - mapper.get "/foo(/:id)", to: "foo#bar", as: 'gorby' + mapper.get "/foo(/:id)", to: "foo#bar", as: "gorby" assert_not_equal ast, routes.ast end def test_simulator_changes - mapper.get "/foo(/:id)", to: "foo#bar", as: 'aaron' + mapper.get "/foo(/:id)", to: "foo#bar", as: "aaron" sim = routes.simulator - mapper.get "/foo(/:id)", to: "foo#bar", as: 'gorby' + mapper.get "/foo(/:id)", to: "foo#bar", as: "gorby" assert_not_equal sim, routes.simulator end def test_partition_route - mapper.get "/foo(/:id)", to: "foo#bar", as: 'aaron' + mapper.get "/foo(/:id)", to: "foo#bar", as: "aaron" assert_equal 1, @routes.anchored_routes.length assert_predicate @routes.custom_routes, :empty? - mapper.get "/hello/:who", to: "foo#bar", as: 'bar', who: /\d/ + mapper.get "/hello/:who", to: "foo#bar", as: "bar", who: /\d/ assert_equal 1, @routes.custom_routes.length assert_equal 1, @routes.anchored_routes.length end def test_first_name_wins - mapper.get "/hello", to: "foo#bar", as: 'aaron' + mapper.get "/hello", to: "foo#bar", as: "aaron" assert_raise(ArgumentError) do - mapper.get "/aaron", to: "foo#bar", as: 'aaron' + mapper.get "/aaron", to: "foo#bar", as: "aaron" end end end |