2011-08-10 09:01:22 -04:00
|
|
|
require 'rake'
|
2012-10-19 08:19:43 -04:00
|
|
|
require 'bundler/gem_tasks'
|
|
|
|
require 'rspec/core/rake_task'
|
2012-10-19 08:12:38 -04:00
|
|
|
|
2012-11-12 02:01:49 -05:00
|
|
|
def run_in_dummy_app(command)
|
|
|
|
success = system("cd spec/dummy && #{command}")
|
|
|
|
raise "#{command} failed" unless success
|
2012-10-25 03:26:32 -04:00
|
|
|
end
|
|
|
|
|
2012-11-12 02:01:49 -05:00
|
|
|
task "default" => "ci"
|
2012-11-02 21:50:09 -04:00
|
|
|
|
2012-10-19 08:12:38 -04:00
|
|
|
desc "Run all tests for CI"
|
2012-11-12 15:31:56 -05:00
|
|
|
task "ci" => "spec"
|
2012-10-19 08:12:38 -04:00
|
|
|
|
2012-11-12 02:01:49 -05:00
|
|
|
desc "Run all specs"
|
|
|
|
task "spec" => "spec:all"
|
|
|
|
|
|
|
|
namespace "spec" do
|
2013-01-12 03:05:06 -05:00
|
|
|
task "all" => ["draper", "generators", "integration"]
|
2012-11-12 02:01:49 -05:00
|
|
|
|
|
|
|
def spec_task(name)
|
|
|
|
desc "Run #{name} specs"
|
|
|
|
RSpec::Core::RakeTask.new(name) do |t|
|
|
|
|
t.pattern = "spec/#{name}/**/*_spec.rb"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
spec_task "draper"
|
|
|
|
spec_task "generators"
|
|
|
|
|
|
|
|
desc "Run integration specs"
|
|
|
|
task "integration" => ["db:setup", "integration:all"]
|
|
|
|
|
|
|
|
namespace "integration" do
|
|
|
|
task "all" => ["development", "production", "test"]
|
|
|
|
|
|
|
|
["development", "production"].each do |environment|
|
|
|
|
task environment do
|
|
|
|
Rake::Task["spec:integration:run"].execute environment
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
task "run" do |t, environment|
|
|
|
|
puts "Running integration specs in #{environment}"
|
|
|
|
|
|
|
|
ENV["RAILS_ENV"] = environment
|
|
|
|
success = system("rspec spec/integration")
|
|
|
|
|
|
|
|
raise "Integration specs failed in #{environment}" unless success
|
|
|
|
end
|
|
|
|
|
|
|
|
task "test" do
|
2013-01-12 03:05:06 -05:00
|
|
|
puts "Running rake in dummy app"
|
|
|
|
ENV["RAILS_ENV"] = "test"
|
2012-11-12 02:01:49 -05:00
|
|
|
run_in_dummy_app "rake"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
namespace "db" do
|
|
|
|
desc "Set up databases for integration testing"
|
|
|
|
task "setup" do
|
2013-01-19 11:31:26 -05:00
|
|
|
puts "Setting up databases"
|
2012-11-12 02:01:49 -05:00
|
|
|
run_in_dummy_app "rm -f db/*.sqlite3"
|
2013-01-12 03:05:06 -05:00
|
|
|
run_in_dummy_app "RAILS_ENV=development rake db:schema:load db:seed"
|
2012-11-12 02:01:49 -05:00
|
|
|
run_in_dummy_app "RAILS_ENV=production rake db:schema:load db:seed"
|
2013-01-12 03:05:06 -05:00
|
|
|
run_in_dummy_app "RAILS_ENV=test rake db:schema:load"
|
2012-11-12 02:01:49 -05:00
|
|
|
end
|
|
|
|
end
|