1 |
|
2 | should = require('chai').should()
|
3 | rack = require '../.'
|
4 | express = require 'express.io'
|
5 | easyrequest = require 'request'
|
6 | fs = require 'fs'
|
7 |
|
8 | describe 'a static asset builder', ->
|
9 | app = null
|
10 |
|
11 | it 'should work', (done) ->
|
12 | staticPath = "#{__dirname}/fixtures/static"
|
13 | compiled = fs.readFileSync "#{staticPath}/blank.txt", 'utf8'
|
14 | app = express().http()
|
15 | app.use new rack.StaticAssets
|
16 | dirname: staticPath
|
17 | urlPrefix: '/static'
|
18 | app.listen 7076, ->
|
19 | easyrequest 'http://localhost:7076/static/blank.txt', (error, response, body) ->
|
20 | response.headers['content-type'].should.equal 'text/plain'
|
21 | body.should.equal compiled
|
22 | done()
|
23 |
|
24 | afterEach (done) -> process.nextTick ->
|
25 | app.server.close done
|