handler_test.rb 637 B

123456789101112131415161718192021222324252627282930313233
  1. require 'test_helper'
  2. class HandlerTest < DAV4RackTest
  3. class DummyController < Struct.new(:request, :response, :options)
  4. include DAV4Rack::HTTPStatus
  5. def authenticate
  6. end
  7. def process
  8. response.body = request.request_method
  9. OK
  10. end
  11. end
  12. def setup
  13. super
  14. @handler = DAV4Rack::Handler.new(controller_class: DummyController)
  15. end
  16. def test_should_instantiate_controller_and_call_corresponding_method
  17. status, headers, body = @handler.call env_for(:get, '/')
  18. assert_equal 'GET', body.body.join
  19. assert_equal '3', headers['Content-Length']
  20. assert_equal 200, status
  21. end
  22. end