Module: Teaspoon::Environment

Defined in:
lib/teaspoon/environment.rb

Class Method Summary collapse

Class Method Details

.load(options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/teaspoon/environment.rb', line 6

def self.load(options = {})
  require_environment(options[:environment])
  raise "Rails environment not found." unless rails_loaded?

  require "teaspoon"
  require "teaspoon/server"
  require "teaspoon/runner"
  require "teaspoon/coverage"
  require "teaspoon/exporter"

  Teaspoon.configuration.override_from_options(options)
  Teaspoon::ExceptionHandling.add_rails_handling
end

.require_environment(override = nil) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/teaspoon/environment.rb', line 20

def self.require_environment(override = nil)
  override ||= ENV["TEASPOON_ENV"]
  if override
    override = File.expand_path(override, Dir.pwd)
    ENV["TEASPOON_ENV"] = override
    return require_env(override)
  end

  standard_environments.each do |filename|
    file = File.expand_path(filename, Dir.pwd)
    return require_env(file) if File.exists?(file)
    #file = File.expand_path(filename, File.join(Dir.pwd, '../..'))
    #return require_env(file) if File.exists?(file)
  end

  raise Teaspoon::EnvironmentNotFound, "Unable to load Teaspoon environment in {#{standard_environments.join(', ')}}"
end

.standard_environmentsObject



38
39
40
# File 'lib/teaspoon/environment.rb', line 38

def self.standard_environments
  ["spec/teaspoon_env.rb", "test/teaspoon_env.rb", "teaspoon_env.rb"]
end