Sha256: 1cb6e962c4b0e07bc39fa0d0a0c6568a2aeda8a30ec222d6f6126e5b2ceedf02
Contents?: true
Size: 1.92 KB
Versions: 5
Compression:
Stored size: 1.92 KB
Contents
require 'assert' require 'deas/route' require 'deas/exceptions' require 'deas/route_proxy' require 'test/support/fake_sinatra_call' require 'test/support/view_handlers' class Deas::Route class UnitTests < Assert::Context desc "Deas::Route" setup do @req_type_name = Factory.string @proxy = HandlerProxySpy.new @handler_proxies = Hash.new{ |h, k| raise(Deas::HandlerProxyNotFound) }.tap do |h| h[@req_type_name] = @proxy end @route = Deas::Route.new(:get, '/test', @handler_proxies) end subject{ @route } should have_readers :method, :path should have_imeths :validate!, :run should "know its method and path" do assert_equal :get, subject.method assert_equal '/test', subject.path end should "validate its proxies on validate" do assert_false @proxy.validate_called assert_nothing_raised{ subject.validate! } assert_true @proxy.validate_called end end class RunTests < UnitTests desc "when run" setup do @fake_sinatra_call = FakeSinatraCall.new end should "run the proxy for the given request type name" do Assert.stub(@fake_sinatra_call.settings.router, :request_type_name).with( @fake_sinatra_call.request ){ @req_type_name } @route.run(@fake_sinatra_call) assert_true @proxy.run_called end should "halt 404 if it can't find a proxy for the given request type name" do halt_value = catch(:halt) do @route.run(@fake_sinatra_call) end assert_equal [404], halt_value end end class HandlerProxySpy attr_reader :validate_called, :run_called, :sinatra_call def initialize @run_called = false @validate_called = false @sinatra_call = nil end def validate! @validate_called = true end def run(sinatra_call) @sinatra_call = sinatra_call @run_called = true end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
deas-0.36.0 | test/unit/route_tests.rb |
deas-0.35.0 | test/unit/route_tests.rb |
deas-0.34.0 | test/unit/route_tests.rb |
deas-0.33.0 | test/unit/route_tests.rb |
deas-0.32.0 | test/unit/route_tests.rb |