Class: Greenlight::Scenario

Inherits:
Object
  • Object
show all
Defined in:
lib/greenlight/scenario.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, &block) ⇒ Scenario

Returns a new instance of Scenario.



14
15
16
17
# File 'lib/greenlight/scenario.rb', line 14

def initialize(name, &block)
  self.name = name
  self.body = block
end

Instance Attribute Details

#bodyObject

tests - hash of tests



12
13
14
# File 'lib/greenlight/scenario.rb', line 12

def body
  @body
end

#nameObject

tests - hash of tests



12
13
14
# File 'lib/greenlight/scenario.rb', line 12

def name
  @name
end

Instance Method Details

#error_msgObject



40
41
42
# File 'lib/greenlight/scenario.rb', line 40

def error_msg
  "SCENARIO '#{name}' failed"
end

#runObject



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

def run
  action Colors.white("SCENARIO ") + Colors.light_magenta(name)
  Console.instance.indent
  ret = Greenlight.eval({}, &body)
  success('scenario succeeded')
  ret
rescue RequestException
  error error_msg
  raise ScenarioException
rescue TestException
  error error_msg
  raise ScenarioException
rescue StandardError => e
  error e.backtrace.inspect
  error e.message
  error error_msg
  raise ScenarioException
ensure
  Console.instance.unindent
end