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:
authorRémy Coutable <remy@rymai.me>2017-10-11 08:59:34 +0300
committerAchilleas Pipinellis <axil@gitlab.com>2017-10-11 08:59:34 +0300
commit676840ff9c4e85e44b2f2c6e7c92f62f834e20aa (patch)
tree4f6bff8253d2dc596bfe0858a64aee12713e4e05 /doc/development/testing_guide/testing_rake_tasks.md
parent150f58decb95977eaff82c51d6ef7043f1589e48 (diff)
Refactor the Development documentation, and divide the Testing documentation into multiple pages
Diffstat (limited to 'doc/development/testing_guide/testing_rake_tasks.md')
-rw-r--r--doc/development/testing_guide/testing_rake_tasks.md39
1 files changed, 39 insertions, 0 deletions
diff --git a/doc/development/testing_guide/testing_rake_tasks.md b/doc/development/testing_guide/testing_rake_tasks.md
new file mode 100644
index 00000000000..5bf185dd7b5
--- /dev/null
+++ b/doc/development/testing_guide/testing_rake_tasks.md
@@ -0,0 +1,39 @@
+## Testing Rake tasks
+
+To make testing Rake tasks a little easier, there is a helper that can be included
+in lieu of the standard Spec helper. Instead of `require 'spec_helper'`, use
+`require 'rake_helper'`. The helper includes `spec_helper` for you, and configures
+a few other things to make testing Rake tasks easier.
+
+At a minimum, requiring the Rake helper will redirect `stdout`, include the
+runtime task helpers, and include the `RakeHelpers` Spec support module.
+
+The `RakeHelpers` module exposes a `run_rake_task(<task>)` method to make
+executing tasks simple. See `spec/support/rake_helpers.rb` for all available
+methods.
+
+Example:
+
+```ruby
+require 'rake_helper'
+
+describe 'gitlab:shell rake tasks' do
+ before do
+ Rake.application.rake_require 'tasks/gitlab/shell'
+
+ stub_warn_user_is_not_gitlab
+ end
+
+ describe 'install task' do
+ it 'invokes create_hooks task' do
+ expect(Rake::Task['gitlab:shell:create_hooks']).to receive(:invoke)
+
+ run_rake_task('gitlab:shell:install')
+ end
+ end
+end
+```
+
+---
+
+[Return to Testing documentation](index.md)