diff --git a/core_dsl.go b/core_dsl.go index c8a1a76a6..bdb908606 100644 --- a/core_dsl.go +++ b/core_dsl.go @@ -421,7 +421,23 @@ var XDescribe = PDescribe var Context, FContext, PContext, XContext = Describe, FDescribe, PDescribe, XDescribe /* When is an alias for Describe - it generates the exact same kind of Container node */ -var When, FWhen, PWhen, XWhen = Describe, FDescribe, PDescribe, XDescribe +func When(text string, args ...interface{}) bool { + return pushNode(internal.NewNode(deprecationTracker, types.NodeTypeContainer, "when "+text, args...)) +} + +/* When is an alias for Describe - it generates the exact same kind of Container node */ +func FWhen(text string, args ...interface{}) bool { + args = append(args, internal.Focus) + return pushNode(internal.NewNode(deprecationTracker, types.NodeTypeContainer, "when "+text, args...)) +} + +/* When is an alias for Describe - it generates the exact same kind of Container node */ +func PWhen(text string, args ...interface{}) bool { + args = append(args, internal.Pending) + return pushNode(internal.NewNode(deprecationTracker, types.NodeTypeContainer, "when "+text, args...)) +} + +var XWhen = PWhen /* It nodes are Subject nodes that contain your spec code and assertions. diff --git a/integration/progress_test.go b/integration/progress_test.go index b93c6046d..09142d46f 100644 --- a/integration/progress_test.go +++ b/integration/progress_test.go @@ -56,7 +56,7 @@ var _ = Describe("Emitting progress", func() { Ω(session).Should(gbytes.Say(`\[BeforeEach\] Inner Context`)) Ω(session).Should(gbytes.Say(`>inner before<`)) - Ω(session).Should(gbytes.Say(`\[BeforeEach\] Inner When`)) + Ω(session).Should(gbytes.Say(`\[BeforeEach\] when Inner When`)) Ω(session).Should(gbytes.Say(`>inner before<`)) Ω(session).Should(gbytes.Say(`\[JustBeforeEach\] ProgressFixture`)) diff --git a/internal/suite_test.go b/internal/suite_test.go index a94bbc8c4..18a7bed63 100644 --- a/internal/suite_test.go +++ b/internal/suite_test.go @@ -384,5 +384,11 @@ var _ = Describe("Suite", func() { }) }) }) + + When("using when", func() { + It("prepends 'when' to the test name", func() { + Ω(CurrentSpecReport().FullText()).Should(ContainSubstring(" when using when prepends")) + }) + }) }) })