Sha256: 85cc6b2720ab8ff766c80150585ced63a513db05923df54d870460dd388f5531
Contents?: true
Size: 1.93 KB
Versions: 2
Compression:
Stored size: 1.93 KB
Contents
require File.join(File.dirname(__FILE__), 'CONFIG.rb') require 'test/unit' require 'ostruct' require 'glue' require 'glue/logger' require 'nitro' class TC_Controller < Test::Unit::TestCase # :nodoc: all include Nitro class Blog1Controller < Controller def list end end class Blog2Controller < Controller attr_reader :aqflag, :tflag def self.setup_template_root(path) @template_root << File.expand_path(File.join(Nitro::LibPath, "../test/public/#{path}")) end def list @aqflag = true end def another(oid) # nop end private def encode_myself encode_url :list end def encode_blog1 encode_url Blog1Controller, :list end end def setup @disp = Dispatcher.new({ '/blog' => Blog2Controller, '/blog1' => Blog1Controller }) @conf = OpenStruct.new @conf.dispatcher = @disp end def test_render ctx = Context.new(@conf) ctx.headers = {} ctx.params = {} ctx.headers['REQUEST_URI'] = '/blog/list' ctx.instance_eval '@session = {}' klass, action = ctx.dispatcher.dispatch(ctx.path, ctx) c = klass.new(ctx) begin c.send(action) rescue RenderExit # drink end assert_equal('/blog/list', c.send(:encode_myself)) assert_equal('/blog1/list', c.send(:encode_blog1)) # handle action with arity. assert_equal('/blog/another/32', c.send(:encode_url, :another, :oid, 32)) assert_equal true, c.aqflag assert_equal true, $include1 assert_equal true, $include2 # the template is compiled assert_equal true, c.tflag end def test_action_methods # aflag/tflag are counted too! # p Blog2Controller.action_methods # FIXME: the next 5 should be 3!! # assert_equal 5, Blog2Controller.action_methods.size assert Blog2Controller.action_methods.include?('list') end def test_encode_decode_methods end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
nitro-0.30.0 | test/nitro/tc_controller.rb |
nitro-0.31.0 | test/nitro/tc_controller.rb |