Sha256: 8c14cac37af3734573db89bc633786aaca5cd311c585384e464ff4e64a003583

Contents?: true

Size: 1.28 KB

Versions: 13

Compression:

Stored size: 1.28 KB

Contents

class Teabag.Reporters.HTML.SpecView extends Teabag.Reporters.BaseView

  viewId = 0

  constructor: (@spec, @reporter) ->
    @views = @reporter.views
    @spec.viewId = viewId += 1
    @views.specs[@spec.viewId] = @
    super


  build: ->
    classes = ["spec"]
    classes.push("state-pending") if @spec.pending
    super(classes.join(" "))
    @el.innerHTML = """<a href="#{@spec.link}">#{@spec.description}</a>"""
    @parentView = @buildParent()
    @parentView.append(@el)


  buildParent: ->
    parent = @spec.parent
    if parent.viewId
      @views.suites[parent.viewId]
    else
      view = new Teabag.Reporters.HTML.SuiteView(parent, @reporter)
      @views.suites[view.suite.viewId] = view


  buildErrors: ->
    div = @createEl("div")
    html = ""
    for error in @spec.errors()
      html += """<strong>#{@htmlSafe(error.message)}</strong><br/>#{@htmlSafe(error.stack || "Stack trace unavailable")}"""
    div.innerHTML = html
    @append(div)


  updateState: (state, elapsed) ->
    result = @spec.result()
    classes = ["state-#{state}"]
    classes.push("slow") if elapsed > Teabag.slow
    @el.innerHTML += "<span>#{elapsed}ms</span>" unless state == "failed"
    @el.className = classes.join(" ")
    @buildErrors() unless result.status == "passed"
    @parentView.updateState?(state)

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
teabag-0.7.3 app/assets/javascripts/teabag/base/reporters/html/spec_view.coffee
teabag-0.7.2 app/assets/javascripts/teabag/base/reporters/html/spec_view.coffee
teabag-0.7.1 app/assets/javascripts/teabag/base/reporters/html/spec_view.coffee
teabag-0.7.0 app/assets/javascripts/teabag/base/reporters/html/spec_view.coffee
teabag-0.6.0 app/assets/javascripts/teabag/base/reporters/html/spec_view.coffee
teabag-0.5.5 app/assets/javascripts/teabag/base/reporters/html/spec_view.coffee
teabag-0.5.4 app/assets/javascripts/teabag/base/reporters/html/spec_view.coffee
teabag-0.5.3 app/assets/javascripts/teabag/base/reporters/html/spec_view.coffee
teabag-0.5.2 app/assets/javascripts/teabag/base/reporters/html/spec_view.coffee
teabag-0.5.1 app/assets/javascripts/teabag/base/reporters/html/spec_view.coffee
teabag-0.5.0 app/assets/javascripts/teabag/base/reporters/html/spec_view.coffee
teabag-0.4.6 app/assets/javascripts/teabag/base/reporters/html/spec_view.coffee
teabag-0.4.5 app/assets/javascripts/teabag/base/reporters/html/spec_view.coffee