From 1b05516762304a4296ac1d13e37751ed3d6d9442 Mon Sep 17 00:00:00 2001 From: Washington Botelho Date: Wed, 14 Feb 2018 14:43:26 -0200 Subject: [PATCH] up: add rake to run spec with config enabled --- Rakefile | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Rakefile b/Rakefile index dc8c23d..c3c8075 100644 --- a/Rakefile +++ b/Rakefile @@ -5,3 +5,21 @@ require 'rspec/core/rake_task' RSpec::Core::RakeTask.new task default: :spec + +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