Sha256: d4470a84f59eb98e125f1abcd0ed4792bc321c8a68afbef540e65475637a9171

Contents?: true

Size: 914 Bytes

Versions: 1

Compression:

Stored size: 914 Bytes

Contents

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

module Orats
  module Test
    include Commands::New::Server

    BINARY_PATH = File.absolute_path('../../bin/orats', __FILE__)
    TEST_PATH   = '/tmp/orats/test'
    ORATS_FLAGS = '--pg-password pleasedonthackme --skip-server-start'

    def orats(command, options = {})
      cmd, app_name   = command.split(' ')
      prepend_command = ''

      command         = "#{cmd} #{TEST_PATH}/#{app_name}" if command.include?(' ')

      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

1 entries across 1 versions & 1 rubygems

Version Path
orats-0.6.5 test/test_helper.rb