Sha256: d6d9dc844e75b7e4d36080e246769a38de3944bef356f10df1a5a6e17b160823

Contents?: true

Size: 1.39 KB

Versions: 1

Compression:

Stored size: 1.39 KB

Contents

# Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
# License:   Apache License, Version 2.0

$LOAD_PATH.unshift File.join(File.dirname(__FILE__), "/../lib")

require 'spec'
require 'rtm'

def implementation_for_spec
  engine = ENV['RTM_IMPLEMENTATION'] && ENV['RTM_IMPLEMENTATION'].to_sym || :ontopia # if env is nil, the "normal progress will go on" # TODO: remove ontopia, as it should be chosen by connect by default
end

def get_used_tm_sys
  if implementation_for_spec == :majortom_db
    begin
      $database_params ||= YAML.load_file(File.join(File.dirname(__FILE__), "/database_config.yml"))["database_params"]
    rescue
      raise("You need to define the database_config.yml in rtm/spec.")
    end
    connection = RTM.connect($database_params)
  else
    connection = RTM.connect(:implementation => implementation_for_spec)
  end
  return connection
end

def get_used_tm_sys_tm
  connection = get_used_tm_sys
  
  begin
    tm = connection.create("http://www.topicmapslab.de/")
  rescue Exception => e
    print_stack_trace(e)
    raise(e.message)
  end

  if implementation_for_spec == :majortom_db
    tm.clear
  end
  # tm.enable_query_cache
  return tm
end

def ar_available?
  !Gem.source_index.find_name('activerecord').empty?
end

def print_stack_trace(e)
  puts "\nError because of:"
  puts e.message
  while e.cause
    puts "and because of:"
    e = e.cause
    puts e.message
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rtm-0.3.1 spec/spec_helper.rb