Sha256: 3b713ca46841128b63fd9af5cbe19a691d53e3100fd40508ef4d04ae89f362f6

Contents?: true

Size: 1.5 KB

Versions: 12

Compression:

Stored size: 1.5 KB

Contents

require 'assert'
require 'deas/route_proxy'

require 'deas/exceptions'
require 'deas/handler_proxy'
require 'test/support/empty_view_handler'

class Deas::RouteProxy

  class UnitTests < Assert::Context
    desc "Deas::RouteProxy"
    setup do
      @proxy = Deas::RouteProxy.new('EmptyViewHandler')
    end
    subject{ @proxy }

    should "be a HandlerProxy" do
      assert_kind_of Deas::HandlerProxy, subject
    end

    should "complain if given a nil handler class name" do
      assert_raises(Deas::NoHandlerClassError) do
        Deas::RouteProxy.new(nil)
      end
    end

    should "apply no view handler ns if none given" do
      assert_equal 'EmptyViewHandler', subject.handler_class_name
    end

    should "apply an optional view handler ns if it is given" do
      proxy = Deas::RouteProxy.new('NsTest', 'MyStuff')
      assert_equal 'MyStuff::NsTest', proxy.handler_class_name
    end

    should "ignore the ns when given a class name with leading colons" do
      proxy = Deas::RouteProxy.new('::NoNsTest', 'MyStuff')
      assert_equal '::NoNsTest', proxy.handler_class_name
    end

    should "set its handler class on `validate!`" do
      assert_nil subject.handler_class

      assert_nothing_raised{ subject.validate! }
      assert_equal EmptyViewHandler, subject.handler_class
    end

    should "complain if there is no handler class with the given name" do
      assert_raises(Deas::NoHandlerClassError) do
        Deas::RouteProxy.new('SomethingNotDefined').validate!
      end
    end

  end

end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
deas-0.43.5 test/unit/route_proxy_tests.rb
deas-0.43.4 test/unit/route_proxy_tests.rb
deas-0.43.3 test/unit/route_proxy_tests.rb
deas-0.43.2 test/unit/route_proxy_tests.rb
deas-0.43.1 test/unit/route_proxy_tests.rb
deas-0.43.0 test/unit/route_proxy_tests.rb
deas-0.42.0 test/unit/route_proxy_tests.rb
deas-0.41.0 test/unit/route_proxy_tests.rb
deas-0.40.0 test/unit/route_proxy_tests.rb
deas-0.39.2 test/unit/route_proxy_tests.rb
deas-0.39.1 test/unit/route_proxy_tests.rb
deas-0.39.0 test/unit/route_proxy_tests.rb