Sha256: 94df46ca6b3fbca9a2017524794783fc38adbdfa6c843213b1836b4f6ae25ae9

Contents?: true

Size: 1.21 KB

Versions: 1

Compression:

Stored size: 1.21 KB

Contents

require 'rake'
require 'rake/testtask'
require 'bundler/gem_tasks'

def execute(command)
  puts command
  system command
end

def bundle_options
  return '' unless ENV['BUNDLE_GEMFILE']

  "--gemfile #{ENV['BUNDLE_GEMFILE']}"
end

def each_database(&block)
  ['sqlite', 'postgres', 'mysql'].each &block
end

namespace :bundle do
  task :env do
    ar = ENV['AR'].to_s

    next if ar.empty?

    gemfile = "gemfiles/Gemfile.rails_#{ar}"
    raise "Cannot find gemfile at #{gemfile}" unless File.exist?(gemfile)

    ENV['BUNDLE_GEMFILE'] = gemfile
    puts "Using gemfile: #{gemfile}"
  end

  task install: :env do
    execute "bundle install #{bundle_options}"
  end

  task update: :env do
    execute "bundle update #{bundle_options}"
  end

  task :install_all do
    [nil, '3', '4', '5', '6', 'head'].each do |ar|
      opt = ar && "AR=#{ar}"
      execute "rake bundle:install #{opt}"
    end
  end
end

task :test do
  each_database { |db| execute "rake #{db}:test" }
end

Rake::TestTask.new :_test do |t|
  t.libs << 'test'
  t.pattern = 'test/**/*_test.rb'
  t.verbose = false
end

each_database do |db|
  namespace db do
    task(:env) { ENV['DB'] = db }
    task test: ['env', 'bundle:env', '_test']
  end
end

task default: :test

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
i18n-active_record-0.4.1 Rakefile