File tree Expand file tree Collapse file tree 1 file changed +48
-1
lines changed
Expand file tree Collapse file tree 1 file changed +48
-1
lines changed Original file line number Diff line number Diff line change @@ -237,6 +237,8 @@ describe '#summary' do
237237end
238238----
239239
240+ == Example Group Structure
241+
240242=== Leading `subject`
241243
242244When `subject` is used, it should be the first declaration in the example group.
@@ -272,7 +274,52 @@ describe Article do
272274end
273275----
274276
275- == Example Group Structure
277+ === Declaring `subject`, `let!`/`let` and `before`/`after` hooks
278+
279+ When declaring `subject`, `let!`/`let` and `before`/`after` hooks they should be in the following order:
280+
281+ * `subject`
282+ * `let!`/`let`
283+ * `before`/`after`
284+
285+ [source,ruby]
286+ ----
287+ # bad
288+ describe Article do
289+ before do
290+ # ...
291+ end
292+
293+ after do
294+ # ...
295+ end
296+
297+ let(:user) { FactoryBot.create(:user) }
298+ subject { FactoryBot.create(:some_article) }
299+
300+ describe '#summary' do
301+ # ...
302+ end
303+ end
304+
305+ # good
306+ describe Article do
307+ subject { FactoryBot.create(:some_article) }
308+ let(:user) { FactoryBot.create(:user) }
309+
310+ before do
311+ # ...
312+ end
313+
314+ after do
315+ # ...
316+ end
317+
318+ describe '#summary' do
319+ # ...
320+ end
321+ end
322+ ----
276323
277324=== Use Contexts
278325
You can’t perform that action at this time.
0 commit comments