Sha256: cb98f86ac0e22bd15f71c2d55ca21bf4032769111e5e42cc95bd30fe3847aa81
Contents?: true
Size: 1.76 KB
Versions: 3
Compression:
Stored size: 1.76 KB
Contents
$:.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib') require 'test/unit' require 'nitro' class TC_Dispatcher < Test::Unit::TestCase # :nodoc: all include Nitro Template.root = File.expand_path(File.join('..', 'public')) class MyContext attr_accessor :headers def initialize @headers = {} end end 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 }) @ctx = MyContext.new end def teardown @d = @dxml = @ctx = nil end def test_initialize d = Dispatcher.new(BlogController) assert_equal BlogController, d.controllers['/'] end def test_dispatch klass, action = @d.dispatch('/blog/list', @ctx) assert_equal BlogController, klass assert_equal 'list_action', action klass, action = @d.dispatch('/blog/another/very_litle', @ctx) assert_equal BlogController, klass assert_equal 'another__very_litle_action', action =begin klass, action = @d.dispatch('/another/litle/list', @ctx) assert_equal MainController, klass assert_equal 'another__litle__list_action', action klass, action = @d.dispatch('/blog', @ctx) assert_equal BlogController, klass assert_equal 'index_action', action klass, action, ctype = @d.dispatch('/login', @ctx) assert_equal MainController, klass assert_equal 'login_action', action klass, action = @d.dispatch('/', @ctx) assert_equal MainController, klass assert_equal 'index_action', action =end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
nitro-0.26.0 | test/nitro/tc_dispatcher.rb |
nitro-0.27.0 | test/nitro/tc_dispatcher.rb |
nitro-0.28.0 | test/nitro/tc_dispatcher.rb |