class ActionDispatch::Journey::NFA::TestSimulator
Public Instance Methods
simulator_for(paths)
click to toggle source
# File actionpack/test/journey/nfa/simulator_test.rb, line 91 def simulator_for(paths) parser = Journey::Parser.new asts = paths.map { |x| parser.parse x } builder = Builder.new Nodes::Or.new asts Simulator.new builder.transition_table end
test_matchdata_has_memos()
click to toggle source
# File actionpack/test/journey/nfa/simulator_test.rb, line 49 def test_matchdata_has_memos paths = %w{ /foo /bar } parser = Journey::Parser.new asts = paths.map { |x| ast = parser.parse x ast.each { |n| n.memo = ast } ast } expected = asts.first builder = Builder.new Nodes::Or.new asts sim = Simulator.new builder.transition_table md = sim.match "/foo" assert_equal [expected], md.memos end
test_matchdata_memos_on_merge()
click to toggle source
# File actionpack/test/journey/nfa/simulator_test.rb, line 68 def test_matchdata_memos_on_merge parser = Journey::Parser.new routes = [ "/articles(.:format)", "/articles/new(.:format)", "/articles/:id/edit(.:format)", "/articles/:id(.:format)", ].map { |path| ast = parser.parse path ast.each { |n| n.memo = ast } ast } asts = routes.dup ast = Nodes::Or.new routes nfa = Journey::NFA::Builder.new ast sim = Simulator.new nfa.transition_table md = sim.match "/articles" assert_equal [asts.first], md.memos end
test_simulate_optional()
click to toggle source
# File actionpack/test/journey/nfa/simulator_test.rb, line 42 def test_simulate_optional sim = simulator_for ["/foo(/bar)"] assert_match sim, "/foo" assert_match sim, "/foo/bar" assert_no_match sim, "/foo/" end
test_simulate_or()
click to toggle source
# File actionpack/test/journey/nfa/simulator_test.rb, line 35 def test_simulate_or sim = simulator_for ["/foo", "/bar"] assert_match sim, "/bar" assert_match sim, "/foo" assert_no_match sim, "/baz" end
test_simulate_regex()
click to toggle source
# File actionpack/test/journey/nfa/simulator_test.rb, line 29 def test_simulate_regex sim = simulator_for ["/:foo/bar"] assert_match sim, "/bar/bar" assert_match sim, "/foo/bar" end
test_simulate_simple()
click to toggle source
# File actionpack/test/journey/nfa/simulator_test.rb, line 9 def test_simulate_simple sim = simulator_for ["/foo"] assert_match sim, "/foo" end
test_simulate_simple_no_match()
click to toggle source
# File actionpack/test/journey/nfa/simulator_test.rb, line 14 def test_simulate_simple_no_match sim = simulator_for ["/foo"] assert_no_match sim, "foo" end
test_simulate_simple_no_match_too_long()
click to toggle source
# File actionpack/test/journey/nfa/simulator_test.rb, line 19 def test_simulate_simple_no_match_too_long sim = simulator_for ["/foo"] assert_no_match sim, "/foo/bar" end
test_simulate_simple_no_match_wrong_string()
click to toggle source
# File actionpack/test/journey/nfa/simulator_test.rb, line 24 def test_simulate_simple_no_match_wrong_string sim = simulator_for ["/foo"] assert_no_match sim, "/bar" end