Sha256: cf40f0155228bc8e6ef3490a095309128ce83328ee54dd4296ab7da043924c59

Contents?: true

Size: 1.73 KB

Versions: 10

Compression:

Stored size: 1.73 KB

Contents

namespace :signonotron do
  desc "Start signonotron (for integration tests)"
  task :start => :stop do

    @app_to_launch = "signonotron2"

    puts "Launching: #{@app_to_launch}"

    gem_root = Pathname.new(File.dirname(__FILE__)) + '..' + '..'
    FileUtils.mkdir_p(gem_root + 'tmp')
    Dir.chdir gem_root + 'tmp' do
      if File.exist? @app_to_launch
        Dir.chdir @app_to_launch do
          puts `git clean -fdx`
          puts `git fetch origin`
          puts `git reset --hard origin/master`
        end
      else
        puts `git clone git@github.com:alphagov/#{@app_to_launch}`
      end
    end

    Dir.chdir gem_root + 'tmp' + @app_to_launch do
      env_to_clear = %w(BUNDLE_GEMFILE BUNDLE_BIN_PATH RUBYOPT GEM_HOME GEM_PATH)

      env_stuff = case `uname`.strip
      when "Darwin"
        env_to_clear.map { |e| "unset #{e}" }.join(" && ") + " && "
      else
        "/usr/bin/env " + env_to_clear.map { |e| "-u #{e}" }.join(" ")
      end
      env_stuff += " RAILS_ENV=test"

      puts `#{env_stuff} bundle install --path=#{gem_root + 'tmp' + "#{@app_to_launch}_bundle"}`
      FileUtils.cp gem_root.join('spec', 'fixtures', 'integration', "#{@app_to_launch}_database.yml"), File.join('config', 'database.yml')
      puts `#{env_stuff} bundle exec rake db:drop db:create db:schema:load`

      puts "Starting signonotron instance in the background"
      fork do
        Process.daemon(true)
        exec "#{env_stuff} bundle exec rails s -p 4567"
      end
    end
  end

  desc "Stop running signonotron (for integration tests)"
  task :stop do
    pid_output = `lsof -Fp -i :4567`.chomp
    if pid_output =~ /\Ap(\d+)\z/
      puts "Stopping running instance of Signonotron (pid #{$1})"
      Process.kill(:INT, $1.to_i)
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
gds-sso-3.0.5 spec/tasks/signonotron_tasks.rake
gds-sso-3.0.4 spec/tasks/signonotron_tasks.rake
gds-sso-3.0.3 spec/tasks/signonotron_tasks.rake
gds-sso-3.0.2 spec/tasks/signonotron_tasks.rake
gds-sso-3.0.1 spec/tasks/signonotron_tasks.rake
gds-sso-3.0.0 spec/tasks/signonotron_tasks.rake
gds-sso-2.1.0 spec/tasks/signonotron_tasks.rake
gds-sso-2.0.1 spec/tasks/signonotron_tasks.rake
gds-sso-2.0.0 spec/tasks/signonotron_tasks.rake
gds-sso-1.2.2 spec/tasks/signonotron_tasks.rake