Sha256: f2144ecac6869ea8ab6ebfbba9fd255360280f7b8085a83cd9bd6e6a8cb2c3ca

Contents?: true

Size: 1.82 KB

Versions: 2

Compression:

Stored size: 1.82 KB

Contents

describe "Teabag.Runner", ->

  beforeEach ->
    spyOn(jasmine.getEnv(), "execute")
    Teabag.Runner.run = false # reset this so we can use it
    @setupSpy = spyOn(Teabag.Runner.prototype, "setup")

  describe "constructor", ->

    it "calls setup", ->
      new Teabag.Runner()
      expect(@setupSpy).toHaveBeenCalled()

    it "sets Teabag.Runner.run to true", ->
      new Teabag.Runner()
      expect(Teabag.Runner.run).toEqual(true)

    it "sets @fixturePath to whatever was in Teabag.fixturePath", ->
      Teabag.fixturePath = "/path/to/fixtures"
      runner = new Teabag.Runner()
      expect(runner.fixturePath).toEqual("/path/to/fixtures")

    it "doesn't call setup if already run", ->
      Teabag.Runner.run = true
      new Teabag.Runner()
      expect(@setupSpy).wasNotCalled()


  describe "#getParams", ->

    it "gets the params out of the window.location.search", ->
      spyOn(String.prototype, "substring").andReturn("grep=foo&bar=baz")
      runner = new Teabag.Runner()
      expect(runner.params).toEqual(grep: "foo", bar: "baz")


  describe "#getReporter", ->

    it "returns the correct reporter when using PhantomJS", ->
      runner = new Teabag.Runner()
      runner.params = {}
      spyOn(String.prototype, 'match').andReturn(20)
      expect(runner.getReporter()).toBe(Teabag.Reporters.Console)

    it "returns the correct reporter when using the browser", ->
      runner = new Teabag.Runner()
      runner.params = {}
      spyOn(String.prototype, 'match').andReturn(0)
      expect(runner.getReporter()).toBe(Teabag.Reporters.HTML)

    it "allows setting the param", ->
      runner = new Teabag.Runner()
      runner.params = {reporter: "Console"}
      expect(runner.getReporter()).toBe(Teabag.Reporters.Console)
      runner.params = {reporter: "HTML"}
      expect(runner.getReporter()).toBe(Teabag.Reporters.HTML)

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
teabag-0.4.0 spec/javascripts/teabag/base/runner_spec.coffee
teabag-0.3.6 spec/javascripts/teabag/base/runner_spec.coffee