 
   it 'should not flush steps at other hooks', (done) ->
     thisShouldPass
-      before: ->
-        casper.start 'http://bing.com/'
       test: ->
         casper.steps.length.should.be.above 0
     , done

      encoding: 'utf8'
    , (err, template) ->
      throw err if err
      testContents = util.format template, test.reporter or 'spec', test.before or (-> casper.start('sample.html')), test.test, test.after or (->)
      fs.writeFile testfile, testContents, (err) -> throw err if err

  process = spawn('casperjs', [testfile])

      throw new Error 'expected the test to fail with "' + failureText + '" in the failures, but it passed'
    done()

sampleHtml = '<!doctype html>
  <html>
    <head>
      <title>mocha-casperjs tests</title>
    </head>
  <body>
    <h1>Hello World!</h1>
    <article></article>
  </body>
  </html>'

describe 'Mocha Runnable shim', ->
  server = null
  before ->
    server = require('http').createServer (req, res) ->
      echoStatus = req.url?.match(/echo\/(\d+)/)
      if echoStatus?[1]
        res.statusCode = echoStatus[1]
        res.end()
      if req.url is '/sample'
        res.writeHead '200', 
          'Content-Type': 'text/html'
        res.end sampleHtml
    server.listen 10473
  
  it 'should flush all the steps at the end of a test', (done) ->
    thisShouldPass
