mirror of
https://gitlab.com/gitlab-org/gitlab-foss.git
synced 2025-07-25 16:03:48 +00:00
1.1 KiB
1.1 KiB
stage, group, info, title
stage | group | info | title |
---|---|---|---|
none | unassigned | Any user with at least the Maintainer role can merge updates to this content. For details, see https://docs.gitlab.com/development/development_processes/#development-guidelines-review. | Testing Rake tasks |
To make testing Rake tasks a little easier:
- Use RSpec's metadata tag
type: :task
or - Place your spec in
spec/tasks
oree/spec/tasks
By doing so, RakeHelpers
is included which exposes a run_rake_task(<task>)
method to make executing tasks possible.
See spec/support/helpers/rake_helpers.rb
for all available methods.
$stdout
can be redirected by adding :silence_stdout
.
Example:
require 'spec_helper'
describe 'gitlab:shell rake tasks', :silence_stdout 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