From 750ccae50e9876e61f431658ad3e27d412fcfddc Mon Sep 17 00:00:00 2001 From: Andrew Davey Date: Thu, 4 Aug 2011 11:24:01 +0100 Subject: [PATCH] Add test for inner scenario context prototype chaining. --- src/Witness.Specs/OuterScenario.coffee | 47 ++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/src/Witness.Specs/OuterScenario.coffee b/src/Witness.Specs/OuterScenario.coffee index a94cf37..4af2522 100644 --- a/src/Witness.Specs/OuterScenario.coffee +++ b/src/Witness.Specs/OuterScenario.coffee @@ -125,6 +125,53 @@ describe "OuterScenario", inner1ThenCalled: should.be true doneCalled: should.be true }, +{ + "given an OuterScenario in 'do all' mode, with two inner scenarios": -> + testContext = this + parts = + given: [ { + description: "given" + actions: [ new witness.Action (-> testContext.outerContext = this) ] + } ] + + dispose: [] + + innerScenarios = [ + new witness.Scenario({ + given: [ { + description: "given" + actions: [ new witness.Action (-> testContext.innerContext1 = this) ] + } ] + when: [] + then: [] + }), + new witness.Scenario({ + given: [ { + description: "given" + actions: [ new witness.Action (-> testContext.innerContext2 = this) ] + } ] + when: [] + then: [] + }) + ] + @outerScenario = new witness.OuterScenario parts, "all", innerScenarios + + "when it is run": async -> + @outerScenario.run {}, + (=> @done()) + (=> @done()) + + "then outer and inner contexts are different objects": -> + @outerContext != @innerContext1 and + @outerContext != @innerContext2 and + @innerContext1 != @innerContext2 + + "then outer context is prototype of inner context 1": -> + @innerContext1.prototype == @outerContext + + "then outer context is prototype of inner context 2": -> + @innerContext2.prototype == @outerContext +}, { "given an OuterScenario with event handlers added": -> parts =