Sha256: 8e6332c0ceeafbb2150431d7c5e3f28283be5807e80d5b1d3b32acfa43d24847

Contents?: true

Size: 1.51 KB

Versions: 25

Compression:

Stored size: 1.51 KB

Contents

require 'helper'

module Journey
  module Definition
    class TestScanner < MiniTest::Unit::TestCase
      def setup
        @scanner = Scanner.new
      end

      # /page/:id(/:action)(.:format)
      def test_tokens
        [
          ['/',      [[:SLASH, '/']]],
          ['*omg',   [[:STAR, '*'], [:LITERAL, 'omg']]],
          ['/page',  [[:SLASH, '/'], [:LITERAL, 'page']]],
          ['/:page', [[:SLASH, '/'], [:SYMBOL, ':page']]],
          ['/(:page)', [
                        [:SLASH, '/'],
                        [:LPAREN, '('],
                        [:SYMBOL, ':page'],
                        [:RPAREN, ')'],
                      ]],
          ['(/:action)', [
                          [:LPAREN, '('],
                          [:SLASH, '/'],
                          [:SYMBOL, ':action'],
                          [:RPAREN, ')'],
                         ]],
          ['(())', [[:LPAREN, '('],
                   [:LPAREN, '('], [:RPAREN, ')'], [:RPAREN, ')']]],
          ['(.:format)', [
                          [:LPAREN, '('],
                          [:DOT, '.'],
                          [:SYMBOL, ':format'],
                          [:RPAREN, ')'],
                        ]],
        ].each do |str, expected|
          @scanner.scan_setup str
          assert_tokens expected, @scanner
        end
      end

      def assert_tokens tokens, scanner
        toks = []
        while tok = scanner.next_token
          toks << tok
        end
        assert_equal tokens, toks
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 3 rubygems

Version Path
challah-0.6.1 vendor/bundle/gems/journey-1.0.1/test/route/definition/test_scanner.rb
challah-0.6.0 vendor/bundle/gems/journey-1.0.1/test/route/definition/test_scanner.rb
challah-0.5.4 vendor/bundle/gems/journey-1.0.1/test/route/definition/test_scanner.rb
challah-0.5.3 vendor/bundle/gems/journey-1.0.1/test/route/definition/test_scanner.rb
challah-0.5.2 vendor/bundle/gems/journey-1.0.1/test/route/definition/test_scanner.rb
challah-0.5.0 vendor/bundle/gems/journey-1.0.1/test/route/definition/test_scanner.rb
journey-1.0.2 test/route/definition/test_scanner.rb
challah-0.4.1 vendor/bundle/gems/journey-1.0.1/test/route/definition/test_scanner.rb
challah-0.4.0 vendor/bundle/gems/journey-1.0.1/test/route/definition/test_scanner.rb
challah-0.3.5 vendor/bundle/gems/journey-1.0.1/test/route/definition/test_scanner.rb
challah-0.3.4 vendor/bundle/gems/journey-1.0.1/test/route/definition/test_scanner.rb
challah-0.3.3 vendor/bundle/gems/journey-1.0.1/test/route/definition/test_scanner.rb
challah-0.3.2 vendor/bundle/gems/journey-1.0.1/test/route/definition/test_scanner.rb
challah-0.3.1 vendor/bundle/gems/journey-1.0.1/test/route/definition/test_scanner.rb
challah-0.3.0 vendor/bundle/gems/journey-1.0.1/test/route/definition/test_scanner.rb
challah-0.2.1 vendor/bundle/gems/journey-1.0.1/test/route/definition/test_scanner.rb
challah-0.2.0 vendor/bundle/gems/journey-1.0.1/test/route/definition/test_scanner.rb
journey-1.0.1 test/route/definition/test_scanner.rb
andyjeffries-journey-1.0.0.20111022124133 test/route/definition/test_scanner.rb
andyjeffries-journey-1.0.0 test/route/definition/test_scanner.rb