summaryrefslogtreecommitdiff
path: root/doc/development/testing_guide
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2018-05-15 13:27:04 +0000
committerRémy Coutable <remy@rymai.me>2018-05-15 13:27:04 +0000
commit920becb784f3abe95363807b8848f72e9a2260d2 (patch)
tree0eb85fba6e3e2051b621a5359696b288b33bf09e /doc/development/testing_guide
parent2df09a403ba4f97cce034032d0e03cb55a6b65be (diff)
parent7186f0de657f510e27e24b6845f99ded158118af (diff)
downloadgitlab-ce-920becb784f3abe95363807b8848f72e9a2260d2.tar.gz
Merge branch 'backstage/gb/improve-fast-specs-helper' into 'master'
Improve fast specs helper to autoload the library See merge request gitlab-org/gitlab-ce!18903
Diffstat (limited to 'doc/development/testing_guide')
-rw-r--r--doc/development/testing_guide/best_practices.md23
1 files changed, 18 insertions, 5 deletions
diff --git a/doc/development/testing_guide/best_practices.md b/doc/development/testing_guide/best_practices.md
index 9d3f2935127..a76a5096b69 100644
--- a/doc/development/testing_guide/best_practices.md
+++ b/doc/development/testing_guide/best_practices.md
@@ -133,11 +133,24 @@ really fast since:
- gitlab-shell and Gitaly setup are skipped
- Test repositories setup are skipped
-Note that in some cases, you might have to add some `require_dependency 'foo'`
-in your file under test since Rails autoloading is not available in these cases.
-
-This shouldn't be a problem since explicitely listing dependencies should be
-considered a good practice anyway.
+`fast_spec_helper` also support autoloading classes that are located inside the
+`lib/` directory. It means that as long as your class / module is using only
+code from the `lib/` directory you will not need to explicitly load any
+dependencies. `fast_spec_helper` also loads all ActiveSupport extensions,
+including core extensions that are commonly used in the Rails environment.
+
+Note that in some cases, you might still have to load some dependencies using
+`require_dependency` when a code is using gems or a dependency is not located
+in `lib/`.
+
+For example, if you want to test your code that is calling the
+`Gitlab::UntrustedRegexp` class, which under the hood uses `re2` library, you
+should either add `require_dependency 're2'` to files in your library that
+need `re2` gem, to make this requirement explicit, or you can add it to the
+spec itself, but the former is preferred.
+
+It takes around one second to load tests that are using `fast_spec_helper`
+instead of 30+ seconds in case of a regular `spec_helper`.
### `let` variables