Module: Gless

Defined in:
lib/gless.rb,
lib/gless/config.rb,
lib/gless/logger.rb,
lib/gless/browser.rb,
lib/gless/session.rb,
lib/gless/base_page.rb,
lib/gless/wrap_watir.rb

Overview

The Gless module itself only defines a setup method; all the meat is in the other classes, especially Session. See the README for a general overview; it lives at github.com/rlpowell/gless , which is also the home of this project.

Defined Under Namespace

Classes: BasePage, Browser, EnvConfig, Logger, Session, WrapWatir

Constant Summary collapse

VERSION =

The current version number.

'1.5.1'

Class Method Summary collapse

Class Method Details

.setup(tag, hash = nil) {|config| ... } ⇒ Gless::Logger, ...

Sets up the config, logger and browser instances, the ordering of which is slightly tricky. If a block is given, the config, after being initialized from the config file, is passed to the block, which should return the new, updated config.

writing out the replay log and so on. Only really relevant if multiple runs are happening at once.

present, this hash is used intead of reading a config file; the config file is totally ignored in this case.

Parameters:

  • tag (String)

    A short name used in creating log lines and

  • hash (Hash) (defaults to: nil)

    Defaults to nil, which is ignored. If

Yields:

  • (config)

    The config loaded from the development file. The optional block should return an updated config if given.

Returns:



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/gless.rb', line 28

def self.setup( tag, hash = nil )
  logger = Gless::Logger.new( tag )

  # Create the config reading/storage object
  config = Gless::EnvConfig.new( hash )
  config = yield config if block_given?

  # Get the whole backtrace, please.
  if config.get :global, :debug
    ::Cucumber.use_full_backtrace = true

    ::RSpec.configure do |config|
      # RSpec automatically cleans stuff out of backtraces;
      # sometimes this is annoying when trying to debug something e.g. a gem
      config.backtrace_clean_patterns = []
    end
  end

  # Turn on verbose (info) level logging.
  if config.get :global, :verbose
    logger.normal_log.level = ::Logger::INFO
    logger.replay_log.level = ::Logger::INFO
    logger.debug "Verbose/info level logging enabled."
  end

  # Turn on debug level logging.
  if config.get :global, :debug
    logger.normal_log.level = ::Logger::DEBUG
    logger.replay_log.level = ::Logger::DEBUG
    logger.debug "Debug level logging enabled."
  end

  # Create the browser.
  browser = Gless::Browser.new( config, logger )
  browser.cookies.clear

  return logger, config, browser
end