> For the complete documentation index, see [llms.txt](https://ofn-user-guide.gitbook.io/ofn-testing-handbook/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ofn-user-guide.gitbook.io/ofn-testing-handbook/automated-testing-handbook/r-spec-conventions.md).

# (R)Spec Conventions

Some spec conventions on OFN, mostly outputs from code review

* `around`, `before` and `after` blocks go *before* the `it` block. These belong together and makes it easier to understand in which conditions the examples are ran.

For reference see [this review](https://github.com/openfoodfoundation/openfoodnetwork/pull/9165#discussion_r945442755).

* We should not use `I18n.t("key")` on specs but rather use the string it refers to on specs, instead.

For reference see [this discussion](https://openfoodnetwork.slack.com/archives/C02TZ6X00/p1658137192453269) and related issues:

[https://github.com/openfoodfoundation/openfoodnetwork/issues/9499](https://github.com/openfoodfoundation/openfoodnetwork/issues/9500)

<https://github.com/openfoodfoundation/openfoodnetwork/issues/9500>

* Global methods are usually not a good idea: one should include `private` / `def` blocks within the respective `describe / context` blocks.&#x20;

For reference, see [this commit](https://github.com/openfoodfoundation/openfoodnetwork/pull/9165/commits/eb013375b39e49966ce53548bec673a2dbf0ea63).
