Sha256: ea2436ff5602fd2ab4f7d5705d8d93f5e7df99cef2fc23ae9ae230eca14798f7

Contents?: true

Size: 1.31 KB

Versions: 3

Compression:

Stored size: 1.31 KB

Contents

require 'open-uri'

class TestGlobal < Test::Unit::TestCase

  def start_server
    stop_server
    s = `./bin/nephos-server --test -d`
    sleep 1
    s
  end

  def stop_server
    `./bin/nephos-server --test -k`
  end

  def test_simpe_requests_on_app
    start_server
    r = open("http://127.0.0.1:8080/")
    assert_equal "{\"list\":[],\"add\":\"/add\",\"rm\":\"/rm\"}\n", r.read
    assert_equal "application/json; charset=UTF-8", r.meta["content-type"]
    assert_equal "a=b;path=/", r.meta["set-cookie"]
    assert_equal ["200", "OK"], r.status

    r = open("http://127.0.0.1:8080/home")
    assert_equal "{\"list\":[],\"add\":\"/add\",\"rm\":\"/rm\"}\n", r.read
    assert_equal "application/json; charset=UTF-8", r.meta["content-type"]
    assert_equal "a=b;path=/", r.meta["set-cookie"]
    assert_equal ["200", "OK"], r.status

    r = open("http://127.0.0.1:8080/home/")
    assert_equal "{\"list\":[],\"add\":\"/add\",\"rm\":\"/rm\"}\n", r.read
    assert_equal "application/json; charset=UTF-8", r.meta["content-type"]
    assert_equal ["200", "OK"], r.status

    r = open("http://127.0.0.1:8080/hello")
    assert_equal "<html><body><h1>hello world</h1><p>lol</p></body></html>\n", r.read
    assert_equal ["200", "OK"], r.status

    assert_raise do open("http://127.0.0.1:8080/err500") end

    stop_server
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
nephos-server-0.7.2 test/functional/global.rb
nephos-server-0.7.1 test/functional/global.rb
nephos-server-0.7.0 test/functional/global.rb