Sha256: 4390d23f283c2fdd3c906f5d70fce26fa4cbb2ff52afc0fe89aec69c3a514b30
Contents?: true
Size: 1.91 KB
Versions: 1
Compression:
Stored size: 1.91 KB
Contents
$:.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib') require 'test/unit' require 'nitro' class TC_Dispatcher < Test::Unit::TestCase # :nodoc: all include Nitro Glue::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 def list end def another__very_litle end 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 assert_raises(NoActionError) do @d.dispatch('a/nonexistent/action') end =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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
nitro-0.29.0 | test/nitro/tc_dispatcher.rb |