debian-mirror-gitlab/lib/tasks/spec.rake

89 lines
2.1 KiB
Ruby
Raw Normal View History

2019-09-04 21:01:54 +05:30
# frozen_string_literal: true
return if Rails.env.production?
2014-09-02 18:07:02 +05:30
Rake::Task["spec"].clear if Rake::Task.task_defined?('spec')
namespace :spec do
2019-09-04 21:01:54 +05:30
desc 'GitLab | RSpec | Run unit tests'
RSpec::Core::RakeTask.new(:unit, :rspec_opts) do |t, args|
require_dependency 'quality/test_level'
t.pattern = Quality::TestLevel.new.pattern(:unit)
t.rspec_opts = args[:rspec_opts]
end
desc 'GitLab | RSpec | Run integration tests'
RSpec::Core::RakeTask.new(:integration, :rspec_opts) do |t, args|
require_dependency 'quality/test_level'
t.pattern = Quality::TestLevel.new.pattern(:integration)
t.rspec_opts = args[:rspec_opts]
end
desc 'GitLab | RSpec | Run system tests'
RSpec::Core::RakeTask.new(:system, :rspec_opts) do |t, args|
require_dependency 'quality/test_level'
t.pattern = Quality::TestLevel.new.pattern(:system)
t.rspec_opts = args[:rspec_opts]
end
desc '[Deprecated] Use the "bin/rspec --tag api" instead'
2014-09-02 18:07:02 +05:30
task :api do
cmds = [
2017-08-17 22:00:37 +05:30
%w(rake gitlab:setup),
%w(rspec spec --tag @api)
2014-09-02 18:07:02 +05:30
]
run_commands(cmds)
end
2019-09-04 21:01:54 +05:30
desc '[Deprecated] Use the "spec:system" task instead'
2014-09-02 18:07:02 +05:30
task :feature do
cmds = [
2017-08-17 22:00:37 +05:30
%w(rake gitlab:setup),
%w(rspec spec --tag @feature)
2014-09-02 18:07:02 +05:30
]
run_commands(cmds)
end
2019-09-04 21:01:54 +05:30
desc '[Deprecated] Use "bin/rspec spec/models" instead'
2015-12-23 02:04:40 +05:30
task :models do
cmds = [
2017-08-17 22:00:37 +05:30
%w(rake gitlab:setup),
%w(rspec spec --tag @models)
2015-12-23 02:04:40 +05:30
]
run_commands(cmds)
end
2019-09-04 21:01:54 +05:30
desc '[Deprecated] Use "bin/rspec spec/services" instead'
2015-12-23 02:04:40 +05:30
task :services do
cmds = [
2017-08-17 22:00:37 +05:30
%w(rake gitlab:setup),
%w(rspec spec --tag @services)
2015-12-23 02:04:40 +05:30
]
run_commands(cmds)
end
2019-09-04 21:01:54 +05:30
desc '[Deprecated] Use "bin/rspec spec/lib" instead'
2015-12-23 02:04:40 +05:30
task :lib do
cmds = [
2017-08-17 22:00:37 +05:30
%w(rake gitlab:setup),
%w(rspec spec --tag @lib)
2015-12-23 02:04:40 +05:30
]
run_commands(cmds)
end
2014-09-02 18:07:02 +05:30
end
2015-09-11 14:41:01 +05:30
desc "GitLab | Run specs"
2014-09-02 18:07:02 +05:30
task :spec do
cmds = [
2017-08-17 22:00:37 +05:30
%w(rake gitlab:setup),
2017-09-10 17:25:29 +05:30
%w(rspec spec)
2014-09-02 18:07:02 +05:30
]
run_commands(cmds)
end
def run_commands(cmds)
cmds.each do |cmd|
2017-08-17 22:00:37 +05:30
system({ 'RAILS_ENV' => 'test', 'force' => 'yes' }, *cmd) || raise("#{cmd} failed!")
2014-09-02 18:07:02 +05:30
end
end