Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZeger-Jan van de Weg <zegerjan@gitlab.com>2017-04-26 17:46:26 +0300
committerRémy Coutable <remy@rymai.me>2017-04-26 17:46:26 +0300
commit6f5b579f94c4bb3590c56e409434a15b6401afac (patch)
treeb6c1cd04d1e4008151e3a93d9c67bcf5fefdea92 /doc/development/testing.md
parentc7df97710b5b519c8ea1b5bb92ae17579082d3f4 (diff)
Use rspec-set to speed up examples
Diffstat (limited to 'doc/development/testing.md')
-rw-r--r--doc/development/testing.md15
1 files changed, 15 insertions, 0 deletions
diff --git a/doc/development/testing.md b/doc/development/testing.md
index 2c7154f1dea..9b0b9808827 100644
--- a/doc/development/testing.md
+++ b/doc/development/testing.md
@@ -202,6 +202,7 @@ Please consult the [dedicated "Frontend testing" guide](./fe_guide/testing.md).
- Try to follow the [Four-Phase Test][four-phase-test] pattern, using newlines
to separate phases.
- Try to use `Gitlab.config.gitlab.host` rather than hard coding `'localhost'`
+- On `before` and `after` hooks, prefer it scoped to `:context` over `:all`
[four-phase-test]: https://robots.thoughtbot.com/four-phase-test
@@ -225,6 +226,20 @@ so we need to set some guidelines for their use going forward:
[lets-not]: https://robots.thoughtbot.com/lets-not
+#### `set` variables
+
+In some cases there is no need to recreate the same object for tests again for
+each example. For example, a project is needed to test issues on the same
+project, one project will do for the entire file. This can be achieved by using
+`set` in the same way you would use `let`.
+
+`rspec-set` only works on ActiveRecord objects, and before new examples it
+reloads or recreates the model, _only_ if needed. That is, when you changed
+properties or destroyed the object.
+
+There is one gotcha; you can't reference a model defined in a `let` block in a
+`set` block.
+
### Time-sensitive tests
[Timecop](https://github.com/travisjeffery/timecop) is available in our