-
Notifications
You must be signed in to change notification settings - Fork 42
/
Rakefile
66 lines (49 loc) · 2.04 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
$LOAD_PATH << File.expand_path('../lib', __FILE__)
require 'bundler/gem_tasks'
require 'rspec/core/rake_task'
###### RSPEC
RSpec::Core::RakeTask.new(:spec)
RSpec::Core::RakeTask.new(:rcov) do |spec|
spec.rcov = true
end
task :default => :spec
###### TESTBED
desc 'Set up the rails app that the specs and features use'
task :gui_testbed => 'gui_testbed:rebuild'
namespace :gui_testbed do
desc 'Generate a minimal surveyor_gui/surveyor rails app'
task :generate do
sh "bundle exec rails new testbed --skip-bundle" # don't run bundle install until the Gemfile modifications
chdir('testbed') do
gem_file_contents = File.read('Gemfile')
gem_file_contents.sub!(/^(gem 'rails'.*)$/, %Q{ \\1\nplugin_root = File.expand_path('../..', __FILE__)\ngem 'surveyor_gui', :path => plugin_root\ngem 'therubyracer'\ngem 'surveyor', github: 'NUBIC/surveyor'})
File.open('Gemfile', 'w'){|f| f.write(gem_file_contents) }
# not sure why turbolinks gives test problems, anyway better to avoid it?
js_file_contents = File.read('app/assets/javascripts/application.js')
js_file_contents.sub!('//= require turbolinks', '')
File.open('app/assets/javascripts/application.js', 'w'){|f| f.write(js_file_contents) }
Bundler.with_clean_env do
sh 'bundle install' # run bundle install after Gemfile modifications
end
end
end
desc 'Remove the testbed entirely'
task :remove do
rm_rf 'testbed'
end
desc 'Prepare the databases for the testbed'
task :migrate do
chdir('testbed') do
Bundler.with_clean_env do
sh 'bundle exec rails generate simple_form:install'
sh 'bundle exec rake highcharts:update'
sh 'bundle exec rails generate surveyor:install'
sh 'bundle exec rake db:migrate db:test:prepare'
sh 'bundle exec rails generate surveyor_gui:install'
sh 'bundle exec rake db:migrate db:test:prepare'
sh 'bundle exec rake surveyor FILE=surveys/kitchen_sink_survey.rb'
end
end
end
task :rebuild => [:remove, :generate, :migrate]
end