progress_test.go 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. package integration_test
  2. import (
  3. . "github.com/onsi/ginkgo"
  4. . "github.com/onsi/gomega"
  5. "github.com/onsi/gomega/gbytes"
  6. "github.com/onsi/gomega/gexec"
  7. )
  8. var _ = Describe("Emitting progress", func() {
  9. var pathToTest string
  10. var session *gexec.Session
  11. var args []string
  12. BeforeEach(func() {
  13. args = []string{"--noColor"}
  14. pathToTest = tmpPath("progress")
  15. copyIn(fixturePath("progress_fixture"), pathToTest, false)
  16. })
  17. JustBeforeEach(func() {
  18. session = startGinkgo(pathToTest, args...)
  19. Eventually(session).Should(gexec.Exit(0))
  20. })
  21. Context("with the -progress flag, but no -v flag", func() {
  22. BeforeEach(func() {
  23. args = append(args, "-progress")
  24. })
  25. It("should not emit progress", func() {
  26. Ω(session).ShouldNot(gbytes.Say("[bB]efore"))
  27. })
  28. })
  29. Context("with the -v flag", func() {
  30. BeforeEach(func() {
  31. args = append(args, "-v")
  32. })
  33. It("should not emit progress", func() {
  34. Ω(session).ShouldNot(gbytes.Say(`\[BeforeEach\]`))
  35. Ω(session).Should(gbytes.Say(`>outer before<`))
  36. })
  37. })
  38. Context("with the -progress flag and the -v flag", func() {
  39. BeforeEach(func() {
  40. args = append(args, "-progress", "-v")
  41. })
  42. It("should emit progress (by writing to the GinkgoWriter)", func() {
  43. // First spec
  44. Ω(session).Should(gbytes.Say(`\[BeforeEach\] ProgressFixture`))
  45. Ω(session).Should(gbytes.Say(`>outer before<`))
  46. Ω(session).Should(gbytes.Say(`\[BeforeEach\] Inner Context`))
  47. Ω(session).Should(gbytes.Say(`>inner before<`))
  48. Ω(session).Should(gbytes.Say(`\[BeforeEach\] when Inner When`))
  49. Ω(session).Should(gbytes.Say(`>inner before<`))
  50. Ω(session).Should(gbytes.Say(`\[JustBeforeEach\] ProgressFixture`))
  51. Ω(session).Should(gbytes.Say(`>outer just before<`))
  52. Ω(session).Should(gbytes.Say(`\[JustBeforeEach\] Inner Context`))
  53. Ω(session).Should(gbytes.Say(`>inner just before<`))
  54. Ω(session).Should(gbytes.Say(`\[It\] should emit progress as it goes`))
  55. Ω(session).Should(gbytes.Say(`>it<`))
  56. Ω(session).Should(gbytes.Say(`\[AfterEach\] Inner Context`))
  57. Ω(session).Should(gbytes.Say(`>inner after<`))
  58. Ω(session).Should(gbytes.Say(`\[AfterEach\] ProgressFixture`))
  59. Ω(session).Should(gbytes.Say(`>outer after<`))
  60. // Second spec
  61. Ω(session).Should(gbytes.Say(`\[BeforeEach\] ProgressFixture`))
  62. Ω(session).Should(gbytes.Say(`>outer before<`))
  63. Ω(session).Should(gbytes.Say(`\[JustBeforeEach\] ProgressFixture`))
  64. Ω(session).Should(gbytes.Say(`>outer just before<`))
  65. Ω(session).Should(gbytes.Say(`\[It\] should emit progress as it goes`))
  66. Ω(session).Should(gbytes.Say(`>specify<`))
  67. Ω(session).Should(gbytes.Say(`\[AfterEach\] ProgressFixture`))
  68. Ω(session).Should(gbytes.Say(`>outer after<`))
  69. })
  70. })
  71. })