class LapisLazuli::Scenario

Stores the Cucumber scenario Includes timing, running state and a name

Attributes

check_browser_errors[RW]
data[R]
error[R]
id[R]
running[RW]
storage[R]
time[R]
uuid[R]

Public Class Methods

new() click to toggle source
# File lib/lapis_lazuli/scenario.rb, line 22
def initialize
  @uuid = SecureRandom.hex
  @storage = Storage.new
  @running = false
  @name = "start_of_test_run"
  self.update_timestamp
end

Public Instance Methods

scope(cleaned = false) click to toggle source
# File lib/lapis_lazuli/scenario.rb, line 60
def scope(cleaned = false)
  scope = nil
  if @data.respond_to? :backtrace_line
    scope = @data.backtrace_line
  elsif @data.respond_to? :file_colon_line
    scope = @data.file_colon_line
  end

  if scope.nil?
    return nil
  elsif cleaned
    return clean [scope]
  else
    return scope
  end
end
tags() click to toggle source
# File lib/lapis_lazuli/scenario.rb, line 54
def tags
  if !@data.nil?
    return @data.source_tag_names
  end
end
update(scenario) click to toggle source

Update the scenario with a new one

# File lib/lapis_lazuli/scenario.rb, line 32
def update(scenario)
  @uuid = SecureRandom.hex
  # Reset the fail attribute
  @check_browser_errors = true
  # The original scenario from cucumber
  @data = scenario
  # A name without special characters.
  @id = clean(scenario_id(scenario))
  self.update_timestamp
end
update_timestamp() click to toggle source
# File lib/lapis_lazuli/scenario.rb, line 43
def update_timestamp
  now = Time.now
  # The current time
  @time = {
    :timestamp => now.strftime('%y%m%d_%H%M%S'),
    :iso_timestamp => now.utc.strftime("%FT%TZ"),
    :iso_short => now.utc.strftime("%y%m%dT%H%M%SZ"),
    :epoch => now.to_i.to_s
  }
end

Private Instance Methods

clean(strings) click to toggle source
# File lib/lapis_lazuli/scenario.rb, line 79
def clean(strings)
  result = []
  strings.each do |string|
    clean_string = string.gsub(/[^\w\.\-]/, ' ').strip.squeeze(' ').gsub(" ","_")
    result.push(clean_string)
  end
  return result.join("-").squeeze("-")
end