Sha256: a9d4359c65dc17eabafbe96844f1bc9423412d0f5bd1e243824df1017a4137dc

Contents?: true

Size: 1.92 KB

Versions: 2

Compression:

Stored size: 1.92 KB

Contents

#= require teaspoon/base/teaspoon
#= require teaspoon/qunit/reporters/console
#= require teaspoon/qunit/reporters/html

unless QUnit?
  throw new Teaspoon.Error('QUnit not found -- use `suite.use_framework :qunit` and adjust or remove the `suite.javascripts` directive.')

class Teaspoon.Runner extends Teaspoon.Runner

  constructor: ->
    super
    env.start()


  setup: ->
    new (@getReporter())(env)



class Teaspoon.Spec

  constructor: (@spec) ->
    @fullDescription = "#{@spec.module} #{@spec.name}"
    @description = "#{@spec.name} (#{@spec.failed}, #{@spec.passed}, #{@spec.total})"
    @link = "?grep=#{encodeURIComponent("#{@spec.module}: #{@spec.name}")}"
    @parent = if @spec.module then new Teaspoon.Suite({description: @spec.module}) else null
    @suiteName = @spec.module
    @viewId = @spec.viewId
    @pending = false


  errors: ->
    return [] unless @spec.failed
    for item in @spec.assertions
      continue if item.result
      @provideFallbackMessage(item)
      {message: item.message, stack: item.source}


  getParents: ->
    return [] unless @parent
    [@parent]


  result: ->
    status = "failed"
    status = "passed" unless @spec.failed
    status: status
    skipped: false


  provideFallbackMessage: (item) ->
    return if item.message

    if item.actual && item.expected
      item.message ||= "Expected #{JSON.stringify(item.actual)} to equal #{JSON.stringify(item.expected)}"
    else
      item.message = 'failed'



class Teaspoon.Suite

  constructor: (@suite) ->
    @fullDescription = @suite.description
    @description = @suite.description
    @link = "?grep=#{encodeURIComponent(@fullDescription)}"
    @parent = null


# set the environment
env = QUnit
env.config.autostart = false
env.config.altertitle = false
env.config.filter = Teaspoon.Runner.prototype.getParams()["grep"]

window.fixture = Teaspoon.fixture
originalReset = env.reset
env.reset = ->
  originalReset()
  Teaspoon.fixture.cleanup()

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
teaspoon-0.9.1 app/assets/javascripts/teaspoon/qunit.coffee
teaspoon-0.9.0 app/assets/javascripts/teaspoon/qunit.coffee