Sha256: d917ef59806205bdad161ab5e0d1b4bf75ea54bf089137898907564fe289e0a8

Contents?: true

Size: 1.68 KB

Versions: 1

Compression:

Stored size: 1.68 KB

Contents

#
# testing Ruote
#
# since Mon Oct  9 22:19:44 JST 2006
#

require 'ruote/storage/hash_storage'
require 'ruote/storage/fs_storage'


def locate_storage_impl (arg)

  pers = arg[2..-1]

  path = File.expand_path(
    File.join(File.dirname(__FILE__), %w[ .. .. .. ], "ruote-#{pers}"))

  (File.exist?(path) && File.directory?(path)) ? [ pers, path ] : nil
end

#
# Returns the class of the engine to use, based on the ARGV
#
def determine_storage (opts)

  if ARGV.include?('--help')
    puts %{

ARGUMENTS for functional tests :

  --fs  : uses Ruote::FsStorage

else uses the in-memory Ruote::Engine (fastest, but no persistence at all)

    }
    exit 0
  end

  ps = ARGV.select { |a| a.match(/^--/) }
  ps.delete('--split')

  persistent = opts.delete(:persistent)

  if ps.include?('--fs')

    begin
      require 'yajl'
    rescue LoadError
      require 'json'
    end
    Rufus::Json.detect_backend

    Ruote::FsStorage.new('work', opts)

  elsif not ps.empty?

    pers = nil
    ps.each do |a|
      pers = locate_storage_impl(a)
      break if pers
    end

    raise "no persistence found (#{ps.inspect})" unless pers

    lib, path = pers
    $:.unshift(File.join(path, 'lib'))

    begin
      load File.join(path, %w[ test functional_connection.rb ])
    rescue LoadError => le
      begin
        load File.join(path, %w[ test integration_connection.rb ])
      rescue LoadError => lee
        p le
        p lee
        raise lee
      end
    end

    new_storage(opts)

  elsif persistent

    begin
      require 'yajl'
    rescue LoadError
      require 'json'
    end
    Rufus::Json.detect_backend

    Ruote::FsStorage.new('work', opts)

  else

    Ruote::HashStorage.new(opts)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruote-2.1.11 test/functional/storage_helper.rb