Skip to content

Commit acbca72

Browse files
committed
Use new When() synonym
1 parent a31eda7 commit acbca72

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+175
-175
lines changed

format/format_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -338,13 +338,13 @@ var _ = Describe("Format", func() {
338338
})
339339

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

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

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

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

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

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

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

644-
Context("when passed a stringer", func() {
644+
When("passed a stringer", func() {
645645
It("should use what String() returns", func() {
646646
Expect(Object(Stringer{}, 1)).Should(ContainSubstring("<format_test.Stringer>: string"))
647647
})

gbytes/io_wrappers_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ var _ = Describe("Io Wrappers", func() {
6262
timeoutCloser = TimeoutCloser(innerCloser, 20*time.Millisecond)
6363
})
6464

65-
Context("when the underlying Closer closes with no error", func() {
65+
When("the underlying Closer closes with no error", func() {
6666
BeforeEach(func() {
6767
innerCloser = FakeCloser{}
6868
})
@@ -72,7 +72,7 @@ var _ = Describe("Io Wrappers", func() {
7272
})
7373
})
7474

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

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

107-
Context("when the underlying Reader returns no error", func() {
107+
When("the underlying Reader returns no error", func() {
108108
BeforeEach(func() {
109109
innerReader = FakeReader{}
110110
})
@@ -118,7 +118,7 @@ var _ = Describe("Io Wrappers", func() {
118118
})
119119
})
120120

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

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

154-
Context("when the underlying Writer returns no error", func() {
154+
When("the underlying Writer returns no error", func() {
155155
BeforeEach(func() {
156156
innerWriter = FakeWriter{}
157157
})
@@ -163,7 +163,7 @@ var _ = Describe("Io Wrappers", func() {
163163
})
164164
})
165165

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

177-
Context("when the underlying Writer hangs", func() {
177+
When("the underlying Writer hangs", func() {
178178
BeforeEach(func() {
179179
innerWriter = FakeWriter{err: fmt.Errorf("boom"), duration: time.Hour}
180180
})

gbytes/say_matcher_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ var _ = Describe("SayMatcher", func() {
2525
buffer.Write([]byte("abc"))
2626
})
2727

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

37-
Context("when a match is found", func() {
37+
When("a match is found", func() {
3838
It("should succeed", func() {
3939
Expect(buffer).Should(Say("abc"))
4040
})
@@ -60,12 +60,12 @@ var _ = Describe("SayMatcher", func() {
6060
})
6161
})
6262

63-
Context("when no match is found", func() {
63+
When("no match is found", func() {
6464
It("should not error", func() {
6565
Expect(buffer).ShouldNot(Say("def"))
6666
})
6767

68-
Context("when the buffer is closed", func() {
68+
When("the buffer is closed", func() {
6969
BeforeEach(func() {
7070
buffer.Close()
7171
})
@@ -97,7 +97,7 @@ var _ = Describe("SayMatcher", func() {
9797
})
9898
})
9999

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

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

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

142-
Context("when actual is a BufferProvider", func() {
142+
When("actual is a BufferProvider", func() {
143143
It("should use actual's buffer", func() {
144144
s := &speaker{
145145
buffer: NewBuffer(),

gexec/build_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
var packagePath = "./_fixture/firefly"
1515

1616
var _ = Describe(".Build", func() {
17-
Context("when there have been previous calls to Build", func() {
17+
When("there have been previous calls to Build", func() {
1818
BeforeEach(func() {
1919
_, err := gexec.Build(packagePath)
2020
Expect(err).ShouldNot(HaveOccurred())

gexec/session_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ var _ = Describe("Session", func() {
270270
})
271271
})
272272

273-
Context("when the command exits", func() {
273+
When("the command exits", func() {
274274
It("should close the buffers", func() {
275275
Eventually(session).Should(Exit())
276276

@@ -292,7 +292,7 @@ var _ = Describe("Session", func() {
292292
})
293293
})
294294

295-
Context("when wrapping out and err", func() {
295+
When("wrapping out and err", func() {
296296
var (
297297
outWriterBuffer, errWriterBuffer *Buffer
298298
)
@@ -317,7 +317,7 @@ var _ = Describe("Session", func() {
317317
Expect(errWriterBuffer.Contents()).Should(Equal(session.Err.Contents()))
318318
})
319319

320-
Context("when discarding the output of the command", func() {
320+
When("discarding the output of the command", func() {
321321
BeforeEach(func() {
322322
outWriter = ioutil.Discard
323323
errWriter = ioutil.Discard

ghttp/test_server.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ A more comprehensive example is available at https://onsi.github.io/gomega/#_tes
3737
))
3838
})
3939
40-
Context("when requesting all sprockets", func() {
41-
Context("when the response is successful", func() {
40+
When("requesting all sprockets", func() {
41+
When("the response is successful", func() {
4242
BeforeEach(func() {
4343
sprockets = []Sprocket{
4444
NewSprocket("Alfalfa"),
@@ -51,7 +51,7 @@ A more comprehensive example is available at https://onsi.github.io/gomega/#_tes
5151
})
5252
})
5353
54-
Context("when the response is missing", func() {
54+
When("the response is missing", func() {
5555
BeforeEach(func() {
5656
statusCode = http.StatusNotFound
5757
})
@@ -61,7 +61,7 @@ A more comprehensive example is available at https://onsi.github.io/gomega/#_tes
6161
})
6262
})
6363
64-
Context("when the response fails to authenticate", func() {
64+
When("the response fails to authenticate", func() {
6565
BeforeEach(func() {
6666
statusCode = http.StatusUnauthorized
6767
})
@@ -73,7 +73,7 @@ A more comprehensive example is available at https://onsi.github.io/gomega/#_tes
7373
})
7474
})
7575
76-
Context("when the response is a server failure", func() {
76+
When("the response is a server failure", func() {
7777
BeforeEach(func() {
7878
statusCode = http.StatusInternalServerError
7979
})
@@ -86,7 +86,7 @@ A more comprehensive example is available at https://onsi.github.io/gomega/#_tes
8686
})
8787
})
8888
89-
Context("when requesting some sprockets", func() {
89+
When("requesting some sprockets", func() {
9090
BeforeEach(func() {
9191
sprockets = []Sprocket{
9292
NewSprocket("Alfalfa"),

0 commit comments

Comments
 (0)