File: test_strexp.rb

package info (click to toggle)
ruby-journey 1.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 288 kB
  • sloc: ruby: 2,817; yacc: 42; makefile: 2
file content (30 lines) | stat: -rw-r--r-- 812 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
require 'helper'

module Journey
  class Router
    class TestStrexp < MiniTest::Unit::TestCase
      def test_many_names
        exp = Strexp.new(
          "/:controller(/:action(/:id(.:format)))",
          {:controller=>/.+?/},
          ["/", ".", "?"],
          true)

        assert_equal ["controller", "action", "id", "format"], exp.names
      end

      def test_names
        {
          "/bar(.:format)"    => %w{ format },
          ":format"           => %w{ format },
          ":format-"          => %w{ format },
          ":format0"          => %w{ format0 },
          ":format1,:format2" => %w{ format1 format2 },
        }.each do |string, expected|
          exp = Strexp.new(string, {}, ["/", ".", "?"])
          assert_equal expected, exp.names
        end
      end
    end
  end
end