Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tag: v0.1.5
Fetching contributors…

Cannot retrieve contributors at this time

file 35 lines (31 sloc) 1.719 kb
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
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require File.expand_path('../config/application', __FILE__)
require 'rake'

require 'resque/tasks'
require 'resque_scheduler/tasks'
task "resque:setup" => :environment do
  Resque.before_fork = Proc.new { ActiveRecord::Base.establish_connection } # 第二次执行resque任务时失败 PGError: ERROR: prepared statement "a3" already exists 参考 http://j.mp/rpVqhc http://j.mp/rqj9CQ ;Rails已经打了补丁,未发布版本 http://j.mp/ntPQMr
end

task :travis do
  parallel_size = 4
  unit_test = ENV['UNIT_TEST']
  integrate_test = ENV['INTEGRATE_TEST']
  all_files = Dir.chdir(Rails.root) { Dir["spec/**/*_spec.rb"]}.sort
  integrate_files = Dir.chdir(Rails.root) { Dir["spec/requests/**/*_spec.rb"]}.sort
  unit_files = all_files - integrate_files
  %w(shop/shops_searches_spec.rb lookup_spec.rb).each do |searchable_spec|
    integrate_files.delete "spec/requests/#{searchable_spec}" # 需要solr才能运行
  end
  files = if unit_test # 4个并发
          unit_files.in_groups(parallel_size)[unit_test.to_i-1].join(' ')
        elsif integrate_test # 4个并发
          integrate_files.in_groups(parallel_size)[integrate_test.to_i-1].join(' ')
        end
  cmd = "rspec #{files}"
  #cmd = "rspec spec/requests/shop/shop_orders_spec.rb spec/requests/shop/shop_customers_spec.rb" # selenium-webdriver 2.14未清空session,按此顺序运行,第二个用例失败
  puts "Starting to run #{cmd}..."
  system("export DISPLAY=:99.0 && bundle exec #{cmd}")
  raise "#{cmd} failed!" unless $?.exitstatus == 0
end

Shopqi::Application.load_tasks
Something went wrong with that request. Please try again.