Test suite for oojspec

Don't worry, it is supposed to fail so that you can have an idea about the reporter: https://github.com/rosenfeld/oojspec-test http://oojspec.herokuapp.com/

HTML

<script src="http://oojspec.herokuapp.com/assets/oojspec.js"></script>
<link rel="stylesheet" href="http://oojspec.herokuapp.com/assets/oojspec.css">

CoffeeScript

expectedFailures = expectedErrors = expectedTimeouts = 0

oojspec.describe "First spec", ->
  b1 = b2 = a1 = a2 = 0
  @before -> ++b1
  @before -> ++b2
  @after ->  ++a1
  @after ->  ++a2

  @example 'pass with 2 assertions', ->
    @expect(true).toBe true
    @assert true

  expectedFailures++
  @example 'fail with one assertion', ->
    @assert false
    throw 'should never be executed'
    @assert true

  @describe 'inner describe', -> @it 'passes', -> @assert true

  expectedErrors++
  @context 'inner context', -> @it 'throws', ->
    @describe "describe shouldn't be available here"

  expectedTimeouts++
  expectedFailures++
  @it 'times out', ->
    @waitsFor "waiting for false - will never run", 30, -> false
    @runs -> throw "Should never get here"

  @it 'does not time out', ->
    a = false
    setTimeout (-> a = true), 100
    @waitsFor -> a
    @runs -> @assert true

  @specify "before and after work", ->
    @expect(b1).toBe 7
    @expect(b2).toBe 7
    @expect(a1).toBe 6
    @expect(a2).toBe 6

  @specify "this should be the last test and pass", ->
    @expect(oojspec.stats.failures).toBe expectedFailures
    @expect(oojspec.stats.errors).toBe expectedErrors
    @expect(oojspec.stats.timeouts).toBe expectedTimeouts
    # top-level describes: 'First spec', 'Second context', 'After all description',
    # 'Bare class' and 'JavaScript-like with binding'
    @expect(oojspec.stats.contexts).toBe 5

oojspec.exposeAll()

b = bAll = a = aAll = 0
describe "Second context", ->
  @pending 'pending example'

  @it 'works with async steps', ->
    waiting = true
    setTimeout (-> waiting = false), 20
    @waitsFor -> not waiting
    @runs -> @refute waiting

  @before 'first before', -> throw 'unexpected' unless a is b++
  @before -> throw 'unexpected' unless b > 0
  @beforeAll -> throw 'unexpected' unless aAll is bAll++
  @after 'after', -> throw 'unexpected' unless ++a is b
  @afterAll 'afterAll', -> throw 'unexpected' unless ++aAll is bAll

  @example...