Sha256: f26ab0d014dbb218c59617397a1f3122bbe4b4cf43c027e6d25eb0b1ee644fdb

Contents?: true

Size: 1.48 KB

Versions: 3

Compression:

Stored size: 1.48 KB

Contents

require 'minitest/autorun'
require 'securerandom'
require_relative '../lib/orats/commands/project/server'

module Orats
  module Test
    include Commands::Project::Server

    TEST_PATH         = ENV['TEST_PATH']         || '/tmp/orats'
    POSTGRES_LOCATION = ENV['POSTGRES_LOCATION'] || 'localhost'
    POSTGRES_USERNAME = ENV['POSTGRES_USERNAME'] || 'postgres'
    POSTGRES_PASSWORD = ENV['POSTGRES_PASSWORD'] || 'pleasedonthackme'
    REDIS_LOCATION    = ENV['REDIS_LOCATION']    || 'localhost'
    REDIS_PASSWORD    = ENV['REDIS_PASSWORD']    || ''

    CREDENTIALS = "-l #{POSTGRES_LOCATION} -u #{POSTGRES_USERNAME} -p #{POSTGRES_PASSWORD} -n #{REDIS_LOCATION} -d #{REDIS_PASSWORD}"

    INCLUDES_PATH   = File.absolute_path('../../lib/orats/templates/includes',
                                         __FILE__)
    BINARY_PATH     = File.absolute_path('../../bin/orats', __FILE__)
    ORATS_NEW_FLAGS = "#{CREDENTIALS} -S"

    def orats(command, options = {})
      cmd, app_name   = command.split(' ')
      prepend_command = ''
      command         = "#{cmd} #{TEST_PATH}/#{app_name}" unless app_name.nil?

      if options.has_key?(:answer)
        options[:answer] == 'y' || options[:answer] == 'yes' ?
            insert_answer = 'yes' : insert_answer = 'echo'

        prepend_command = "#{insert_answer} | "
      end

      system "#{prepend_command} #{BINARY_PATH} #{command} #{options[:flags]}"
    end

    private

    def generate_app_name
      "a_#{SecureRandom.hex(8)}"
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
orats-0.7.3 test/test_helper.rb
orats-0.7.2 test/test_helper.rb
orats-0.7.1 test/test_helper.rb