Module: TraceView::Test

Defined in:
lib/traceview/test.rb

Class Method Summary collapse

Class Method Details

.gemfileObject

gemfile

Used to determine under which gemfile we are running. This method will return the name of the active gemfile



44
45
46
# File 'lib/traceview/test.rb', line 44

def gemfile
  File.basename(ENV['BUNDLE_GEMFILE']).split('.').first
end

.gemfile?(name) ⇒ Boolean

gemfile?

Method used to determine under which gemfile we’re running. Pass name as the gemfile name only (without the .gemfile extension)

returns true or fase depending on result

Returns:

  • (Boolean)


34
35
36
# File 'lib/traceview/test.rb', line 34

def gemfile?(name)
  File.basename(ENV['BUNDLE_GEMFILE']) == (name.to_s + '.gemfile')
end

.load_extrasObject

load_extras

This method simply loads all the extras needed to run tests such as models, jobs etc…



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/traceview/test.rb', line 13

def load_extras
  # If we're using the libraries gemfile (with sidekiq and resque)
  if TV::Test.gemfile?(:libraries)
    # Load all of the test workers
    pattern = File.join(File.dirname(__FILE__), '../../test/jobs/**/', '*.rb')
    Dir.glob(pattern) do |f|
      TV.logger.debug "Loading test job file: #{File.basename(f)}"
      require f
    end
  end
end

.set_mysql2_envObject

set_mysql2_env

Used to set the mysql specific DATABASE_URL env based on various conditions



79
80
81
82
83
84
85
# File 'lib/traceview/test.rb', line 79

def set_mysql2_env
  if ENV.key?('TRAVIS_MYSQL_PASS')
    ENV['DATABASE_URL'] = "mysql2://root:#{ENV['TRAVIS_MYSQL_PASS']}@127.0.0.1:3306/travis_ci_test"
  else
    ENV['DATABASE_URL'] = 'mysql2://[email protected]:3306/travis_ci_test'
  end
end

.set_mysql_envObject

set_mysql_env

Used to set the mysql specific DATABASE_URL env based on various conditions



66
67
68
69
70
71
72
# File 'lib/traceview/test.rb', line 66

def set_mysql_env
  if ENV.key?('TRAVIS_MYSQL_PASS')
    ENV['DATABASE_URL'] = "mysql://root:#{ENV['TRAVIS_MYSQL_PASS']}@127.0.0.1:3306/travis_ci_test"
  else
    ENV['DATABASE_URL'] = 'mysql://[email protected]:3306/travis_ci_test'
  end
end

.set_postgresql_envObject

set_postgresql_env

Used to set the postgresql specific DATABASE_URL env based on various conditions



53
54
55
56
57
58
59
# File 'lib/traceview/test.rb', line 53

def set_postgresql_env
  if ENV.key?('TRAVIS_PSQL_PASS')
    ENV['DATABASE_URL'] = "postgresql://postgres:#{ENV['TRAVIS_PSQL_PASS']}@127.0.0.1:5432/travis_ci_test"
  else
    ENV['DATABASE_URL'] = 'postgresql://[email protected]:5432/travis_ci_test'
  end
end