Sha256: 7b38b89e349eec4725107b51eae3e7dfa0a5cc60fe1e655919e54107161a0b19
Contents?: true
Size: 1.89 KB
Versions: 1
Compression:
Stored size: 1.89 KB
Contents
$:.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib') require 'test/unit' require 'nitro/dispatcher' class TC_Dispatcher < Test::Unit::TestCase # :nodoc: all include Nitro class MainController < Controller end class BlogController < Controller end def setup @d = Dispatcher.new({ '/' => MainController, '/blog' => BlogController }) @dxml = Dispatcher.new({ '/' => MainController, '/blog' => BlogController, # FIXME: this is a hack! 'xml:blog' => BlogController }) end def teardown @d = @dxml = nil end def test_initialize d = Dispatcher.new(BlogController) assert_equal BlogController, d.controllers['/'] end def test_dispatch klass, action = @d.dispatch('/blog/list') assert_equal BlogController, klass assert_equal 'list_action', action klass, action = @d.dispatch('/blog/another/very_litle/list') assert_equal BlogController, klass assert_equal 'another__very_litle__list_action', action klass, action = @d.dispatch('/another/litle/list') assert_equal MainController, klass assert_equal 'another__litle__list_action', action klass, action = @d.dispatch('/blog') assert_equal BlogController, klass assert_equal 'index_action', action klass, action, ctype = @d.dispatch('/login') assert_equal MainController, klass assert_equal 'login_action', action klass, action = @d.dispatch('/') assert_equal MainController, klass assert_equal 'index_action', action =begin # gmosx: this functionality is deprecated. Use multiple # controller to define multiple apis. # multi-api dispatcher. # no xml prefix, use xhtml api. klass, action = @dxml.dispatch('/blog/list') assert_equal BlogController, klass assert_equal 'list_action', action # xml prefix, use xml api. klass, action = @dxml.dispatch('/xml:blog/list') assert_equal BlogController, klass assert_equal 'list_action', action =end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
nitro-0.20.0 | test/nitro/tc_dispatcher.rb |