Ω(log.Source).Should(Equal("ginkgo")) Ω(log.Message).Should(Equal("spec.end")) Ω(log.Session).Should(Equal("1")) Ω(log.Data["summary"]).Should(Equal(jsonRoundTrip(SpecSummary{ Name: []string{"A", "B"}, Location: "file/b:4", State: "PASSED", Passed: true, RunTime: time.Minute, }))) }) }) Context("when the spec fails", func() { BeforeEach(func() { summary.State = types.SpecStateFailed summary.Failure = types.SpecFailure{ Message: "something failed!", Location: types.CodeLocation{ FileName: "some/file", LineNumber: 3, FullStackTrace: "some-stack-trace", }, } }) It("should error", func() { reporter.SpecDidComplete(summary) log := fetchLogs()[1] Ω(log.LogLevel).Should(Equal(lager.ERROR)) Ω(log.Source).Should(Equal("ginkgo"))
}) }) }) Describe("SpecDidComplete", func() { JustBeforeEach(func() { reporter.SpecDidComplete(spec) }) BeforeEach(func() { spec = &types.SpecSummary{} }) Context("When the spec passed", func() { BeforeEach(func() { spec.State = types.SpecStatePassed }) Context("When the spec was a measurement", func() { BeforeEach(func() { spec.IsMeasurement = true }) It("should announce the measurement", func() { Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceSuccesfulMeasurement", spec, false))) }) }) Context("When the spec is slow", func() { BeforeEach(func() { spec.RunTime = time.Second
}) It("should POST the SpecSummary to the Ginkgo server", func() { Ω(poster.posts).Should(HaveLen(1)) Ω(poster.posts[0].url).Should(Equal("http://127.0.0.1:7788/SpecWillRun")) Ω(poster.posts[0].bodyType).Should(Equal("application/json")) var summary *types.SpecSummary err := json.Unmarshal(poster.posts[0].bodyContent, &summary) Ω(err).ShouldNot(HaveOccurred()) Ω(summary).Should(Equal(specSummary)) }) Context("When a spec completes", func() { BeforeEach(func() { specSummary.State = types.SpecStatePanicked reporter.SpecDidComplete(specSummary) }) It("should POST the SpecSummary to the Ginkgo server and include any intercepted output", func() { Ω(poster.posts).Should(HaveLen(2)) Ω(poster.posts[1].url).Should(Equal("http://127.0.0.1:7788/SpecDidComplete")) Ω(poster.posts[1].bodyType).Should(Equal("application/json")) var summary *types.SpecSummary err := json.Unmarshal(poster.posts[1].bodyContent, &summary) Ω(err).ShouldNot(HaveOccurred()) specSummary.CapturedOutput = interceptor.InterceptedOutput Ω(summary).Should(Equal(specSummary)) })