테스트 Rake 작업
Rake 작업을 테스트하는 것을 조금 더 쉽게 하려면:
- RSpec의 메타데이터 태그
type: :task
를 사용하거나, -
spec/tasks
또는ee/spec/tasks
에 귀속하게 하세요.
이렇게 함으로써 RakeHelpers
가 포함되어 작업을 실행할 수 있는 run_rake_task(<task>)
메서드를 노출합니다.
모든 사용 가능한 메서드를 확인하려면 spec/support/helpers/rake_helpers.rb
를 참조하세요.
:silence_stdout
를 추가하여 $stdout
를 리디렉션할 수 있습니다.
예시:
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