begin require 'bundler/gem_tasks' rescue LoadError task :gem end begin require 'rspec/core/rake_task' RSpec::Core::RakeTask.new(:spec) do |task| if @jenkins task.rspec_opts = [ '--format', 'RspecJunitFormatter', '--out', 'target/rspec.xml', '--format', 'documentation' ] end end rescue LoadError task :spec end begin require 'rspec/core/rake_task' RSpec::Core::RakeTask.new(:integration) do |task| task.pattern = 'integration/**/*_spec.rb' if @jenkins task.rspec_opts = [ '--format', 'RspecJunitFormatter', '--out', 'target/integration.xml', '--format', 'documentation' ] end end rescue LoadError task :integration end begin require 'rubocop/rake_task' RuboCop::RakeTask.new do |task| if @jenkins task.requires = [ 'rubocop/formatter/checkstyle_formatter' ] task.formatters = [ 'simple', 'RuboCop::Formatter::CheckstyleFormatter' ] task.options = %w(--out target/rubocop.xml) task.fail_on_error = false end end rescue LoadError task :rubocop end desc 'Run all (quick) tests' task test: [:spec, :rubocop] desc 'Run all tests including long running integration tests' task test_integration: [:test, :integration] desc 'Run all tests for jenkins' task :jenkins_prepare do # cleanup target FileUtils.rm_rf 'target' FileUtils.mkdir 'target' @jenkins = true end desc 'Run all quick tests from jenkins' task jenkins: :jenkins_prepare do Rake::Task[:test].invoke end desc 'Run all tests (including integration) from jenkins' task jenkins_integration: :jenkins_prepare do Rake::Task[:test_integration].invoke end task default: :test