Sha256: cc463f806f7f0a33f01d832c3ccfcadb73e68f2b6573ad89d3d9b7bff7933775

Contents?: true

Size: 1.1 KB

Versions: 3

Compression:

Stored size: 1.1 KB

Contents

require 'assert'
require 'test/support/view_handlers'
require 'deas/route_proxy'
require 'deas/route'

class Deas::Route

  class UnitTests < Assert::Context
    desc "Deas::Route"
    setup do
      @handler_proxy = Deas::RouteProxy.new('TestViewHandler')
      @route = Deas::Route.new(:get, '/test', @handler_proxy)
    end
    subject{ @route }

    should have_readers :method, :path, :handler_proxy, :handler_class
    should have_imeths :validate!, :run

    should "know its method and path and handler_proxy" do
      assert_equal :get, subject.method
      assert_equal '/test', subject.path
      assert_equal @handler_proxy, subject.handler_proxy
    end

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

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

    should "complain given an invalid handler class" do
      proxy = Deas::RouteProxy.new('SomethingNotDefined')
      assert_raises(Deas::NoHandlerClassError) do
        Deas::Route.new(:get, '/test', proxy).validate!
      end
    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
deas-0.26.0 test/unit/route_tests.rb
deas-0.25.0 test/unit/route_tests.rb
deas-0.24.1 test/unit/route_tests.rb