Rake 태스크 테스트
Rake 태스크 테스트를 조금 더 쉽게 만들기 위해:
- RSpec의 메타데이터 태그
type: :task
를 사용하거나 -
spec/tasks
또는ee/spec/tasks
에 스펙을 배치하세요
이렇게 하면 RakeHelpers
가 포함되어 run_rake_task(<task>)
메서드가 노출되어 태스크 실행이 가능합니다.
모든 사용 가능한 메서드는 spec/support/helpers/rake_helpers.rb
를 참조하세요.
$stdout
은 :silence_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