Skip to content

Commit

Permalink
Use new When() synonym
Browse files Browse the repository at this point in the history
  • Loading branch information
ansd committed Jan 12, 2020
1 parent a31eda7 commit acbca72
Show file tree
Hide file tree
Showing 41 changed files with 175 additions and 175 deletions.
18 changes: 9 additions & 9 deletions format/format_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,13 +338,13 @@ var _ = Describe("Format", func() {
})

Describe("formatting []byte slices", func() {
Context("when the slice is made of printable bytes", func() {
When("the slice is made of printable bytes", func() {
It("should present it as string", func() {
b := []byte("a b c")
Expect(Object(b, 1)).Should(matchRegexp(`\[\]uint8 \| len:5, cap:\d+`, `a b c`))
})
})
Context("when the slice contains non-printable bytes", func() {
When("the slice contains non-printable bytes", func() {
It("should present it as slice", func() {
b := []byte("a b c\n\x01\x02\x03\xff\x1bH")
Expect(Object(b, 1)).Should(matchRegexp(`\[\]uint8 \| len:12, cap:\d+`, `\[97, 32, 98, 32, 99, 10, 1, 2, 3, 255, 27, 72\]`))
Expand All @@ -367,7 +367,7 @@ var _ = Describe("Format", func() {
Expect(Object(&a, 1)).Should(match(fmt.Sprintf("*int | %p", &a), "3"))
})

Context("when there are pointers to pointers...", func() {
When("there are pointers to pointers...", func() {
It("should recursively deference the pointer until it gets to a value", func() {
a := 3
var b *int
Expand All @@ -381,7 +381,7 @@ var _ = Describe("Format", func() {
})
})

Context("when the pointer points to nil", func() {
When("the pointer points to nil", func() {
It("should say nil and not explode", func() {
var a *AStruct
Expect(Object(a, 1)).Should(match("*format_test.AStruct | 0x0", "nil"))
Expand Down Expand Up @@ -409,7 +409,7 @@ var _ = Describe("Format", func() {
Expect(Object(s, 1)).Should(match("[]bool | len:3, cap:4", "[false, false, false]"))
})

Context("when the slice contains long entries", func() {
When("the slice contains long entries", func() {
It("should format the entries with newlines", func() {
w := []string{"Josiah Edward Bartlet", "Toby Ziegler", "CJ Cregg"}
expected := `[
Expand All @@ -430,7 +430,7 @@ var _ = Describe("Format", func() {
Expect(Object(m, 1)).Should(matchRegexp(`map\[int\]bool \| len:2`, hashMatchingRegexp("3: true", "4: false")))
})

Context("when the slice contains long entries", func() {
When("the slice contains long entries", func() {
It("should format the entries with newlines", func() {
m := map[string][]byte{}
m["Josiah Edward Bartlet"] = []byte("Martin Sheen")
Expand Down Expand Up @@ -459,7 +459,7 @@ var _ = Describe("Format", func() {
Expect(Object(s, 1)).Should(match("format_test.SimpleStruct", `{Name: "Oswald", Enumeration: 17, Veritas: true, Data: "datum", secret: 1983}`))
})

Context("when the struct contains long entries", func() {
When("the struct contains long entries", func() {
It("should format the entries with new lines", func() {
s := &SimpleStruct{
Name: "Mithrandir Gandalf Greyhame",
Expand Down Expand Up @@ -635,13 +635,13 @@ var _ = Describe("Format", func() {
UseStringerRepresentation = false
})

Context("when passed a GoStringer", func() {
When("passed a GoStringer", func() {
It("should use what GoString() returns", func() {
Expect(Object(GoStringer{}, 1)).Should(ContainSubstring("<format_test.GoStringer>: go-string"))
})
})

Context("when passed a stringer", func() {
When("passed a stringer", func() {
It("should use what String() returns", func() {
Expect(Object(Stringer{}, 1)).Should(ContainSubstring("<format_test.Stringer>: string"))
})
Expand Down
18 changes: 9 additions & 9 deletions gbytes/io_wrappers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ var _ = Describe("Io Wrappers", func() {
timeoutCloser = TimeoutCloser(innerCloser, 20*time.Millisecond)
})

Context("when the underlying Closer closes with no error", func() {
When("the underlying Closer closes with no error", func() {
BeforeEach(func() {
innerCloser = FakeCloser{}
})
Expand All @@ -72,7 +72,7 @@ var _ = Describe("Io Wrappers", func() {
})
})

Context("when the underlying Closer closes with an error", func() {
When("the underlying Closer closes with an error", func() {
BeforeEach(func() {
innerCloser = FakeCloser{err: fmt.Errorf("boom")}
})
Expand All @@ -82,7 +82,7 @@ var _ = Describe("Io Wrappers", func() {
})
})

Context("when the underlying Closer hangs", func() {
When("the underlying Closer hangs", func() {
BeforeEach(func() {
innerCloser = FakeCloser{
err: fmt.Errorf("boom"),
Expand All @@ -104,7 +104,7 @@ var _ = Describe("Io Wrappers", func() {
timeoutReader = TimeoutReader(innerReader, 20*time.Millisecond)
})

Context("when the underlying Reader returns no error", func() {
When("the underlying Reader returns no error", func() {
BeforeEach(func() {
innerReader = FakeReader{}
})
Expand All @@ -118,7 +118,7 @@ var _ = Describe("Io Wrappers", func() {
})
})

Context("when the underlying Reader returns an error", func() {
When("the underlying Reader returns an error", func() {
BeforeEach(func() {
innerReader = FakeReader{err: fmt.Errorf("boom")}
})
Expand All @@ -130,7 +130,7 @@ var _ = Describe("Io Wrappers", func() {
})
})

Context("when the underlying Reader hangs", func() {
When("the underlying Reader hangs", func() {
BeforeEach(func() {
innerReader = FakeReader{err: fmt.Errorf("boom"), duration: time.Hour}
})
Expand All @@ -151,7 +151,7 @@ var _ = Describe("Io Wrappers", func() {
timeoutWriter = TimeoutWriter(innerWriter, 20*time.Millisecond)
})

Context("when the underlying Writer returns no error", func() {
When("the underlying Writer returns no error", func() {
BeforeEach(func() {
innerWriter = FakeWriter{}
})
Expand All @@ -163,7 +163,7 @@ var _ = Describe("Io Wrappers", func() {
})
})

Context("when the underlying Writer returns an error", func() {
When("the underlying Writer returns an error", func() {
BeforeEach(func() {
innerWriter = FakeWriter{err: fmt.Errorf("boom")}
})
Expand All @@ -174,7 +174,7 @@ var _ = Describe("Io Wrappers", func() {
})
})

Context("when the underlying Writer hangs", func() {
When("the underlying Writer hangs", func() {
BeforeEach(func() {
innerWriter = FakeWriter{err: fmt.Errorf("boom"), duration: time.Hour}
})
Expand Down
16 changes: 8 additions & 8 deletions gbytes/say_matcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var _ = Describe("SayMatcher", func() {
buffer.Write([]byte("abc"))
})

Context("when actual is not a gexec Buffer, or a BufferProvider", func() {
When("actual is not a gexec Buffer, or a BufferProvider", func() {
It("should error", func() {
failures := InterceptGomegaFailures(func() {
Expect("foo").Should(Say("foo"))
Expand All @@ -34,7 +34,7 @@ var _ = Describe("SayMatcher", func() {
})
})

Context("when a match is found", func() {
When("a match is found", func() {
It("should succeed", func() {
Expect(buffer).Should(Say("abc"))
})
Expand All @@ -60,12 +60,12 @@ var _ = Describe("SayMatcher", func() {
})
})

Context("when no match is found", func() {
When("no match is found", func() {
It("should not error", func() {
Expect(buffer).ShouldNot(Say("def"))
})

Context("when the buffer is closed", func() {
When("the buffer is closed", func() {
BeforeEach(func() {
buffer.Close()
})
Expand Down Expand Up @@ -97,7 +97,7 @@ var _ = Describe("SayMatcher", func() {
})
})

Context("when a positive match fails", func() {
When("a positive match fails", func() {
It("should report where it got stuck", func() {
Expect(buffer).Should(Say("abc"))
buffer.Write([]byte("def"))
Expand All @@ -109,7 +109,7 @@ var _ = Describe("SayMatcher", func() {
})
})

Context("when a negative match fails", func() {
When("a negative match fails", func() {
It("should report where it got stuck", func() {
failures := InterceptGomegaFailures(func() {
Expect(buffer).ShouldNot(Say("abc"))
Expand All @@ -120,7 +120,7 @@ var _ = Describe("SayMatcher", func() {
})
})

Context("when a match is not found", func() {
When("a match is not found", func() {
It("should not fastforward the buffer", func() {
Expect(buffer).ShouldNot(Say("def"))
Expect(buffer).Should(Say("abc"))
Expand All @@ -139,7 +139,7 @@ var _ = Describe("SayMatcher", func() {
})
})

Context("when actual is a BufferProvider", func() {
When("actual is a BufferProvider", func() {
It("should use actual's buffer", func() {
s := &speaker{
buffer: NewBuffer(),
Expand Down
2 changes: 1 addition & 1 deletion gexec/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
var packagePath = "./_fixture/firefly"

var _ = Describe(".Build", func() {
Context("when there have been previous calls to Build", func() {
When("there have been previous calls to Build", func() {
BeforeEach(func() {
_, err := gexec.Build(packagePath)
Expect(err).ShouldNot(HaveOccurred())
Expand Down
6 changes: 3 additions & 3 deletions gexec/session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ var _ = Describe("Session", func() {
})
})

Context("when the command exits", func() {
When("the command exits", func() {
It("should close the buffers", func() {
Eventually(session).Should(Exit())

Expand All @@ -292,7 +292,7 @@ var _ = Describe("Session", func() {
})
})

Context("when wrapping out and err", func() {
When("wrapping out and err", func() {
var (
outWriterBuffer, errWriterBuffer *Buffer
)
Expand All @@ -317,7 +317,7 @@ var _ = Describe("Session", func() {
Expect(errWriterBuffer.Contents()).Should(Equal(session.Err.Contents()))
})

Context("when discarding the output of the command", func() {
When("discarding the output of the command", func() {
BeforeEach(func() {
outWriter = ioutil.Discard
errWriter = ioutil.Discard
Expand Down
12 changes: 6 additions & 6 deletions ghttp/test_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ A more comprehensive example is available at https://onsi.github.io/gomega/#_tes
))
})
Context("when requesting all sprockets", func() {
Context("when the response is successful", func() {
When("requesting all sprockets", func() {
When("the response is successful", func() {
BeforeEach(func() {
sprockets = []Sprocket{
NewSprocket("Alfalfa"),
Expand All @@ -51,7 +51,7 @@ A more comprehensive example is available at https://onsi.github.io/gomega/#_tes
})
})
Context("when the response is missing", func() {
When("the response is missing", func() {
BeforeEach(func() {
statusCode = http.StatusNotFound
})
Expand All @@ -61,7 +61,7 @@ A more comprehensive example is available at https://onsi.github.io/gomega/#_tes
})
})
Context("when the response fails to authenticate", func() {
When("the response fails to authenticate", func() {
BeforeEach(func() {
statusCode = http.StatusUnauthorized
})
Expand All @@ -73,7 +73,7 @@ A more comprehensive example is available at https://onsi.github.io/gomega/#_tes
})
})
Context("when the response is a server failure", func() {
When("the response is a server failure", func() {
BeforeEach(func() {
statusCode = http.StatusInternalServerError
})
Expand All @@ -86,7 +86,7 @@ A more comprehensive example is available at https://onsi.github.io/gomega/#_tes
})
})
Context("when requesting some sprockets", func() {
When("requesting some sprockets", func() {
BeforeEach(func() {
sprockets = []Sprocket{
NewSprocket("Alfalfa"),
Expand Down
Loading

0 comments on commit acbca72

Please sign in to comment.