Class: LapisLazuli::Scenario

Inherits:
Object
  • Object
show all
Includes:
Ast
Defined in:
lib/lapis_lazuli/scenario.rb

Overview

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Ast

#is_cucumber_2?, #is_last_scenario?, #is_scenario?, #is_table_row?, #scenario_id

Constructor Details

#initializeScenario

Returns a new instance of Scenario.



22
23
24
25
26
27
28
# 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

Instance Attribute Details

#check_browser_errorsObject

Returns the value of attribute check_browser_errors.



20
21
22
# File 'lib/lapis_lazuli/scenario.rb', line 20

def check_browser_errors
  @check_browser_errors
end

#dataObject (readonly)

Returns the value of attribute data.



19
20
21
# File 'lib/lapis_lazuli/scenario.rb', line 19

def data
  @data
end

#errorObject (readonly)

Returns the value of attribute error.



19
20
21
# File 'lib/lapis_lazuli/scenario.rb', line 19

def error
  @error
end

#idObject (readonly)

Returns the value of attribute id.



19
20
21
# File 'lib/lapis_lazuli/scenario.rb', line 19

def id
  @id
end

#runningObject

Returns the value of attribute running.



20
21
22
# File 'lib/lapis_lazuli/scenario.rb', line 20

def running
  @running
end

#storageObject (readonly)

Returns the value of attribute storage.



19
20
21
# File 'lib/lapis_lazuli/scenario.rb', line 19

def storage
  @storage
end

#timeObject (readonly)

Returns the value of attribute time.



19
20
21
# File 'lib/lapis_lazuli/scenario.rb', line 19

def time
  @time
end

#uuidObject (readonly)

Returns the value of attribute uuid.



19
20
21
# File 'lib/lapis_lazuli/scenario.rb', line 19

def uuid
  @uuid
end

Instance Method Details

#scope(cleaned = false) ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# 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

#tagsObject



54
55
56
57
58
# File 'lib/lapis_lazuli/scenario.rb', line 54

def tags
  if !@data.nil?
    return @data.source_tag_names
  end
end

#update(scenario) ⇒ Object

Update the scenario with a new one



32
33
34
35
36
37
38
39
40
41
# 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_timestampObject



43
44
45
46
47
48
49
50
51
52
# 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