Module: LapisLazuli

Extended by:
LapisLazuli
Includes:
GenericModule::Assertions, GenericModule::XPath, WorldModule::API, WorldModule::Annotate, WorldModule::Browser, WorldModule::Config, WorldModule::Error, WorldModule::Hooks, WorldModule::Logging, WorldModule::Variable
Included in:
Auth, LapisLazuli, Nav, Register, User
Defined in:
lib/lapis_lazuli/options.rb,
lib/lapis_lazuli.rb,
lib/lapis_lazuli/api.rb,
lib/lapis_lazuli/ast.rb,
lib/lapis_lazuli/cli.rb,
lib/lapis_lazuli/proxy.rb,
lib/lapis_lazuli/browser.rb,
lib/lapis_lazuli/runtime.rb,
lib/lapis_lazuli/storage.rb,
lib/lapis_lazuli/version.rb,
lib/lapis_lazuli/argparse.rb,
lib/lapis_lazuli/scenario.rb,
lib/lapis_lazuli/versions.rb,
lib/lapis_lazuli/world/api.rb,
lib/lapis_lazuli/assertions.rb,
lib/lapis_lazuli/world/error.rb,
lib/lapis_lazuli/world/hooks.rb,
lib/lapis_lazuli/world/proxy.rb,
lib/lapis_lazuli/browser/find.rb,
lib/lapis_lazuli/browser/wait.rb,
lib/lapis_lazuli/placeholders.rb,
lib/lapis_lazuli/world/config.rb,
lib/lapis_lazuli/browser/error.rb,
lib/lapis_lazuli/generic/xpath.rb,
lib/lapis_lazuli/world/browser.rb,
lib/lapis_lazuli/world/logging.rb,
lib/lapis_lazuli/browser/remote.rb,
lib/lapis_lazuli/world/annotate.rb,
lib/lapis_lazuli/world/variable.rb,
lib/lapis_lazuli/generic/assertions.rb,
lib/lapis_lazuli/browser/interaction.rb,
lib/lapis_lazuli/browser/screenshots.rb,
lib/lapis_lazuli/generators/cucumber.rb

Overview

LapisLazuli github.com/spriteCloud/lapis-lazuli

Copyright © 2013-2017 spriteCloud B.V. and other LapisLazuli contributors. All rights reserved.

Defined Under Namespace

Modules: ArgParse, Assertions, Ast, BrowserModule, Generators, GenericModule, WorldModule Classes: API, Browser, CLI, Proxy, Runtime, Scenario, Storage

Constant Summary collapse

CONFIG_OPTIONS =

Configuration options and their default values

{
  "close_browser_after" => ["end", "Close the browser after every scenario, feature, etc. Possible values are 'feature', 'scenario', 'end' and 'never'."],
  "error_strings" => [nil, "List of strings that indicate errors when detected on a web page."],
  "default_env" => [nil, "Indicates which environment specific configuration to load when no test environment is provided explicitly."],
  "test_env" => [nil, "Indicates which environment specific configuration to load in this test run."],
  "browser" => [nil, "Indicates the browser in which to run tests. Possible values are 'firefox', 'chrome', 'safari', 'ie', 'ios'."],
  "email_domain" => ["google.com", "The domain name used when generating email addresses. See the `placeholders` command for more information."],
  "screenshot_on_failure" => [true, "Toggle whether failed scenarios should result in a screenshot being taken automatically."],
  "screenshot_dir" => [".#{File::SEPARATOR}screenshots", "Location prefix for the screenshot path."],
  "screenshots_height" => [nil, "When 'full' the window will be resized to max height before taking a screenshot"],
  "screenshot_scheme" => ["old", "Naming scheme for screenshots. Possible values are 'old' and 'new'. This option will be deprecated in the near future, and only the new scheme will be supported."],
  "breakpoint_on_error" => [false, "If the error() function is used to create errors, should the debugger be started?"],
  "step_pause_time" => [0, "(Deprecated) Number of seconds to wait after each cucumber step is executed."],
  "log_dir" => [".#{File::SEPARATOR}logs", "Location for log files; they'll be named like the configuration file but with the '.log' extension."],
  "log_file" => [nil, "Location of log file; overrides 'log_dir'."],
  "log_level" => ['DEBUG', "Log level; see ruby Logger class for details."],
  "storage_dir" => [".#{File::SEPARATOR}storage", "Location prefix where to output test information file with the '.json' extension."]
}
VERSION =
"2.1.4"
PLACEHOLDERS =

Placeholders and their meanings. The first value is a string to be eval’d to determine the value the placeholder is to be replaced with. The second value describes the meaning.

{
  :timestamp => ['time[:timestamp]', 'The local time at which the test run started.'],
  :iso_timestamp => ['time[:iso_timestamp]', 'The UTC time at which the test run started.'],
  :iso_short => ['time[:iso_short]', 'A shorter version of the UTC time above.'],
  :epoch => ['time[:epoch]', 'An integer representation of the local time above, relative to the epoch.'],
  :email => ['"test_#{uuid}@#{email_domain}"', 'A unique email for the test run (contains the UUID).'],
  :uuid => ['uuid', 'A UUID for the test run.'],
  :scenario_id => ['scenario.id', 'A unique identifier for the current scenario based on the title, in filesystem safe form.'],
  :scenario_timestamp => ['scenario.time[:timestamp]', 'Same as timestamp, but relative to the start of the scenario.'],
  :scenario_iso_timestamp => ['scenario.time[:iso_timestamp]', 'Same as iso_timestamp, but relative to the start of the scenario.'],
  :scenario_iso_short => ['scenario.time[:iso_short]', 'Same as iso_short, but relative to the start of the scenario.'],
  :scenario_epoch => ['scenario.time[:epoch]', 'Same as epoch, but relative to the start of the scenario.'],
  :scenario_email => ['"test_#{uuid}_scenario_#{scenario.uuid}@#{email_domain}"', 'Same as email, but contains the test run UUID and the scenario UUID.'],
  :scenario_uuid => ['scenario.uuid', 'A UUID for the scenario.'],
  :random => ['rand(9999)', 'A random integer <10,000.'],
  :random_small => ['rand(99)', 'A random integer <100.'],
  :random_lange => ['rand(999999)', 'A random integer <1,000,000.'],
  :random_uuid => ['random_uuid', 'A random UUID.'],
  :random_email => ['"test_#{uuid}_random_#{random_uuid}@#{email_domain}"', 'Same as email, but contains the test run and the random UUID.'],
  :versions => ['LapisLazuli.software_versions.nil? ? "" : JSON.generate(LapisLazuli.software_versions)', 'A JSON serialized string of software versions found in e.g. the AfterConfiguration hook.']
}

Constants included from ArgParse

ArgParse::ERROR_OPTIONS

Constants included from WorldModule::Hooks

WorldModule::Hooks::HOOK_QUEUES

Instance Attribute Summary collapse

Class Method Summary collapse

Methods included from Assertions

#assertions, #assertions=

Methods included from GenericModule::XPath

#xp_and, #xp_contains, #xp_not, #xp_or

Methods included from WorldModule::API

#api, #has_api?

Methods included from WorldModule::Browser

#browser, #has_browser?

Methods included from WorldModule::Browser::ClassMethods

#browser_module, #browser_modules

Methods included from WorldModule::Proxy

#has_proxy?, #proxy

Methods included from WorldModule::Logging

#log

Methods included from WorldModule::Config

#add_config_from_file, #config, #current_env, #env, #env_or_config, #get_config_from_file, #has_config?, #has_env?, #has_env_or_config?, #init, #load_config, #metadata, #var_from_env

Methods included from WorldModule::Config::ClassMethods

#add_config, #config_file, #config_file=, #config_files

Methods included from WorldModule::Error

#error, #start_debugger

Methods included from WorldModule::Annotate

#annotate, #annotations

Methods included from ArgParse

#make_list_from_item, #make_list_from_nested, #parse_args

Methods included from WorldModule::Variable

#has_storage?, #scenario, #storage, #time, #uuid, #variable, #variable!

Methods included from WorldModule::Hooks

add_hook, #after_scenario_hook, #before_scenario_hook

Instance Attribute Details

#software_versionsObject

Given a versions string or hash, stores it for later use with the library.



14
15
16
# File 'lib/lapis_lazuli/versions.rb', line 14

def software_versions
  @software_versions
end

Class Method Details

.After(&block) ⇒ Object



65
66
67
# File 'lib/lapis_lazuli.rb', line 65

def self.After(&block)
  LapisLazuli::WorldModule::Hooks.add_hook(:after, block)
end

.Before(&block) ⇒ Object

Export equivalents to cucumber’s Before/After functions



61
62
63
# File 'lib/lapis_lazuli.rb', line 61

def self.Before(&block)
  LapisLazuli::WorldModule::Hooks.add_hook(:before, block)
end

.fetch_versions(url, endpoint = nil) ⇒ Object

Connedt to the endpoint or to ENV, then retrieve the url. The contents should be the software versions used.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/lapis_lazuli/versions.rb', line 20

def self.fetch_versions(url, endpoint = nil)
  # Set the connection endpoint. This is either the endpoint, or the
  # environment variable 'VERSION_ENDPOINT'.
  if ENV.has_key?('VERSION_ENDPOINT')
    endpoint = ENV['VERSION_ENDPOINT']
  end

  # Connect to the endpoint
  api = API.new
  api.set_conn(endpoint)

  # Fetch versions
  response = api.get(url)
  if 2 != response.status / 100
    raise "Error retrieving software versions, got status code #{response.status}"
  end

  # Store that stuff for later.
  self.software_versions = response.body
end

.Start(&block) ⇒ Object



69
70
71
# File 'lib/lapis_lazuli.rb', line 69

def self.Start(&block)
  LapisLazuli::WorldModule::Hooks.add_hook(:start, block)
end