Skip to content

Commit d43c55c

Browse files
authored
Merge pull request zendesk#838 from Darhazer/spec-improvement
Cleanup setting of consecutive return values in stubs
2 parents 8c106b1 + aa85af7 commit d43c55c

File tree

1 file changed

+8
-18
lines changed

1 file changed

+8
-18
lines changed

Diff for: spec/consumer_spec.rb

+8-18
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,10 @@
8080
}
8181

8282
before do
83-
@count = 0
84-
allow(fetcher).to receive(:poll) {
85-
@count += 1
86-
if @count == 1
87-
[:batches, old_fetched_batches]
88-
else
89-
[:batches, fetched_batches]
90-
end
91-
}
83+
allow(fetcher).to receive(:poll).and_return(
84+
[:batches, old_fetched_batches], # first call
85+
[:batches, fetched_batches] # any time after the first call
86+
)
9287
end
9388
end
9489

@@ -121,15 +116,10 @@
121116
}
122117

123118
before do
124-
@count = 0
125-
allow(fetcher).to receive(:poll) {
126-
@count += 1
127-
if @count == 1
128-
[:batches, fetched_batches]
129-
else
130-
[:batches, batches_after_partition_reassignment]
131-
end
132-
}
119+
allow(fetcher).to receive(:poll).and_return(
120+
[:batches, fetched_batches], # first call
121+
[:batches, batches_after_partition_reassignment] # any time after the first call
122+
)
133123
end
134124
end
135125

0 commit comments

Comments
 (0)