Class: Lopata::Environment

Inherits:
Object
  • Object
show all
Defined in:
lib/lopata/environment.rb

Overview

Settings of test enviromnet the scenarios to be runned.

Lopata allows to define different environments the scenarios to be runned on. Set environment name via command line ‘lopata -e stage’ or via configuration:

Lopata.configure do |c|
  c.env = :stage
end

The environment params are loaded from ‘./config/environments/<env>.yml’.

Instance Method Summary collapse

Constructor Details

#initialize(env = Lopata.configuration.env) ⇒ Environment

Loads environment configuration for given env

Parameters:

  • env (Symbol) (defaults to: Lopata.configuration.env)

    environment key Loads golobl configured environment if not given.

See Also:



17
18
19
20
21
22
# File 'lib/lopata/environment.rb', line 17

def initialize(env = Lopata.configuration.env)
  require 'yaml'
  @config = {}
  config_filename = "./config/environments/#{Lopata.configuration.env}.yml"
  @config = YAML::load(File.open(config_filename)) if File.exist?(config_filename)
end

Instance Method Details

#[](key) ⇒ Object

Access to environment settings

Parameters:

  • key (Symbol)

    environment configuration key is set on yml configuration.



26
27
28
# File 'lib/lopata/environment.rb', line 26

def [](key)
  @config[key]
end