Sha256: 7c9bbb59b86e5abba19cfcddf20c941aa25213625e3bf287a607c9bcfbc09c15

Contents?: true

Size: 1.63 KB

Versions: 79

Compression:

Stored size: 1.63 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, '/'], [:LITERAL, '~page']]],
          ['/pa-ge', [[:SLASH, '/'], [:LITERAL, 'pa-ge']]],
          ['/: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

79 entries across 58 versions & 18 rubygems

Version Path
active_mailer-0.0.10 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/journey-1.0.4/test/route/definition/test_scanner.rb
judge-2.0.5 vendor/bundle/ruby/2.1.0/gems/journey-1.0.4/test/route/definition/test_scanner.rb
swipe-rails-0.0.5 vendor/bundle/gems/journey-1.0.4/test/route/definition/test_scanner.rb
active_mailer-0.0.9 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/journey-1.0.4/test/route/definition/test_scanner.rb
active_mailer-0.0.8 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/journey-1.0.4/test/route/definition/test_scanner.rb
active_mailer-0.0.7 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/journey-1.0.4/test/route/definition/test_scanner.rb
active_mailer-0.0.6 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/journey-1.0.4/test/route/definition/test_scanner.rb
font-awesome-rails-3.1.1.2 vendor/ruby/2.0.0/gems/journey-1.0.4/test/route/definition/test_scanner.rb
font-awesome-rails-3.1.1.2 vendor/ruby/1.9.1/gems/journey-1.0.4/test/route/definition/test_scanner.rb
font-awesome-rails-3.1.1.1 vendor/ruby/1.9.1/gems/journey-1.0.4/test/route/definition/test_scanner.rb
font-awesome-rails-3.1.1.1 vendor/ruby/2.0.0/gems/journey-1.0.4/test/route/definition/test_scanner.rb
challah-1.0.0.beta3 vendor/bundle/gems/journey-1.0.4/test/route/definition/test_scanner.rb
fc-webicons-0.0.4 vendor/bundle/ruby/1.9.1/gems/journey-1.0.4/test/route/definition/test_scanner.rb
challah-1.0.0.beta2 vendor/bundle/gems/journey-1.0.4/test/route/definition/test_scanner.rb
challah-1.0.0.beta vendor/bundle/gems/journey-1.0.4/test/route/definition/test_scanner.rb
fc-webicons-0.0.3 vendor/bundle/ruby/1.9.1/gems/journey-1.0.4/test/route/definition/test_scanner.rb
fc-webicons-0.0.2 vendor/bundle/ruby/1.9.1/gems/journey-1.0.4/test/route/definition/test_scanner.rb
fc-webicons-0.0.1 vendor/bundle/ruby/1.9.1/gems/journey-1.0.4/test/route/definition/test_scanner.rb
active_mailer-0.0.5 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/journey-1.0.4/test/route/definition/test_scanner.rb
active_mailer-0.0.4 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/journey-1.0.4/test/route/definition/test_scanner.rb