miti.sh/spec/routes_spec.moon

72 lines
2.7 KiB
Plaintext

http = require "luajit-curl-helper.http"
index_title = "miti.sh · Catalin Constantin Mititiuc"
req = (url) ->
request = http.init url
st = request\perform!
error request\lastError! if not st
request
describe "http://webdevcat.me", ->
it "permanently redirects to http://miti.sh", ->
request = req "http://webdevcat.me"
assert.same request\statusCode!, 301
assert.same request\statusMessage!, "Moved Permanently"
assert.same request\header!.Location, "http://miti.sh/"
describe "http://webdevcat.me/git", ->
it "permanently redirects to http://git.miti.sh/ccm/", ->
request = req "http://webdevcat.me/git"
assert.same request\header!.Location, "http://git.miti.sh/ccm/"
describe "http://webdevcat.me/git/", ->
it "permanently redirects to http://git.miti.sh", ->
request = req "http://webdevcat.me/git"
assert.same request\header!.Location, "http://git.miti.sh/ccm/"
describe "http://webdevcat.me/git/pandoc", ->
it "permanently redirects to http://git.miti.sh/ccm/pandoc", ->
request = req "http://webdevcat.me/git/pandoc"
assert.same request\header!.Location, "http://git.miti.sh/ccm/pandoc"
describe "http://webdevcat.me/apps/btroops", ->
it "permanently redirects to http://apps.miti.sh/btroops", ->
request = req "http://webdevcat.me/apps/btroops"
assert.same request\header!.Location, "http://apps.miti.sh/btroops"
describe "http://miti.sh", ->
it "sends /index.html", ->
request = req "http://miti.sh"
assert.same request\statusCode!, 200
assert.same request\statusMessage!, "OK"
assert.same request\body!\match("<title>(.*)</title>"), index_title
describe "http://miti.sh/index", ->
it "sends /index.html", ->
request = req "http://miti.sh/index"
assert.same request\statusCode!, 200
assert.same request\statusMessage!, "OK"
assert.same request\body!\match("<title>(.*)</title>"), index_title
describe "http://miti.sh/index.html", ->
it "sends /index.html", ->
request = req "http://miti.sh/index.html"
assert.same request\statusCode!, 200
assert.same request\statusMessage!, "OK"
assert.same request\body!\match("<title>(.*)</title>"), index_title
describe "http://miti.sh/posts/", ->
it "permanently redirects to http://miti.sh/posts", ->
request = req "http://miti.sh/posts/"
assert.same request\statusCode!, 301
assert.same request\statusMessage!, "Moved Permanently"
assert.same request\header!.Location, "http://miti.sh/posts"
describe "http://miti.sh/posts", ->
it "sends /posts/index.html", ->
request = req "http://miti.sh/posts"
assert.same request\statusCode!, 200
assert.same request\statusMessage!, "OK"
assert.same request\body!\match("<title>(.*)</title>"), "miti.sh · Posts"