Class: Greenlight::Scenario
- Inherits:
-
Object
- Object
- Greenlight::Scenario
- Defined in:
- lib/greenlight/scenario.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
tests - hash of tests.
-
#name ⇒ Object
tests - hash of tests.
Instance Method Summary collapse
- #error_msg ⇒ Object
-
#initialize(name, &block) ⇒ Scenario
constructor
A new instance of Scenario.
- #run ⇒ Object
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
#body ⇒ Object
tests - hash of tests
12 13 14 |
# File 'lib/greenlight/scenario.rb', line 12 def body @body end |
#name ⇒ Object
tests - hash of tests
12 13 14 |
# File 'lib/greenlight/scenario.rb', line 12 def name @name end |
Instance Method Details
#error_msg ⇒ Object
40 41 42 |
# File 'lib/greenlight/scenario.rb', line 40 def error_msg "SCENARIO '#{name}' failed" end |
#run ⇒ Object
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. error error_msg raise ScenarioException ensure Console.instance.unindent end |