Sha256: 08691c03c5de065b92f0505430c387e4a970f66f107438d7a7c57b9d9a02b1f2
Contents?: true
Size: 1.9 KB
Versions: 2
Compression:
Stored size: 1.9 KB
Contents
require File.join(File.dirname(__FILE__), 'CONFIG.rb') require 'test/unit' require 'nitro' class TC_Dispatcher < Test::Unit::TestCase # :nodoc: all include Nitro 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 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(ActionError) 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
nitro-0.41.0 | test/nitro/tc_dispatcher.rb |
nitro-0.40.0 | test/nitro/tc_dispatcher.rb |