Sha256: 3c0e97c91fee9ccdd346862d307d54436a138905bca655b9a17a526a321c1137

Contents?: true

Size: 984 Bytes

Versions: 5

Compression:

Stored size: 984 Bytes

Contents

class ReqWithWritableParams < Rack::Request
  def params
    return Hash[@env["REQUEST_URI"].gsub(/.*\?(.+)/, '\1').split('&').map{|d| d.split('=')}]
  end
end

class TestNephosServerController < Test::Unit::TestCase

  def test_initialize
    assert_raise do Nephos::Controller.new() end
    assert_raise do Nephos::Controller.new({}) end
    assert_raise do Nephos::Controller.new({}, {}) end

    r = Rack::Request.new({})
    assert_raise do Nephos::Controller.new() end
    assert_raise do Nephos::Controller.new(r) end
    assert_raise do Nephos::Controller.new(r, {}) end
    assert do Nephos::Controller.new(r, {params: []}) end
  end

  def test_controller_params
    r = ReqWithWritableParams.new({"REQUEST_METHOD"=>"GET",
                                   "PATH_INFO"=>"/index",
                                   "REQUEST_URI"=>"/uri?k=v"})
    c = Nephos::Controller.new(r, {params: []})
    assert_equal "v", c.params[:k]
    assert_equal "v", c.params["k"]
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
nephos-server-0.6.5 test/controller.rb
nephos-server-0.6.4 test/controller.rb
nephos-server-0.6.3 test/controller.rb
nephos-server-0.6.2 test/controller.rb
nephos-server-0.6.1 test/controller.rb