2017-10-30 01:44:23 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'rspec/core/rake_task'
|
|
|
|
|
|
|
|
RSpec::Core::RakeTask.new
|
|
|
|
|
|
|
|
task default: :spec
|
2018-02-14 16:43:26 +00:00
|
|
|
|
|
|
|
desc 'Runs tests with config enabled'
|
|
|
|
task :spec_config do
|
|
|
|
directory_config = File.expand_path('config')
|
|
|
|
unsafe_path = ['', '/', '.', './'].include?(directory_config)
|
|
|
|
|
|
|
|
`mkdir -p #{directory_config}`
|
|
|
|
|
|
|
|
File.open(File.expand_path('config/rating.yml'), 'w+') do |file|
|
|
|
|
file.write "rating:\n rate_table: 'reviews'\n rating_table: 'review_ratings'"
|
|
|
|
end
|
|
|
|
|
|
|
|
ENV['CONFIG_ENABLED'] = 'true'
|
|
|
|
|
|
|
|
Rake::Task['spec'].invoke
|
|
|
|
|
|
|
|
FileUtils.rm_rf(directory_config) unless unsafe_path
|
|
|
|
end
|
2018-02-14 17:02:44 +00:00
|
|
|
|
|
|
|
desc 'Runs tests with and without config enabled'
|
|
|
|
task :spec do
|
|
|
|
Rake::Task['spec'].invoke
|
|
|
|
Rake::Task['spec_config'].invoke
|
|
|
|
|
|
|
|
puts "Spec with and without config enabled executed."
|
|
|
|
end
|