Class: Greenlight::Test
- Inherits:
-
Object
- Object
- Greenlight::Test
- Defined in:
- lib/greenlight/test.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
Returns the value of attribute args.
-
#body ⇒ Object
Returns the value of attribute body.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #error_msg ⇒ Object
-
#initialize(name, &block) ⇒ Test
constructor
A new instance of Test.
- #run(args = {}) ⇒ Object
Constructor Details
#initialize(name, &block) ⇒ Test
Returns a new instance of Test.
12 13 14 15 |
# File 'lib/greenlight/test.rb', line 12 def initialize(name, &block) self.name = name self.body = block end |
Instance Attribute Details
#args ⇒ Object
Returns the value of attribute args.
10 11 12 |
# File 'lib/greenlight/test.rb', line 10 def args @args end |
#body ⇒ Object
Returns the value of attribute body.
9 10 11 |
# File 'lib/greenlight/test.rb', line 9 def body @body end |
#name ⇒ Object
Returns the value of attribute name.
8 9 10 |
# File 'lib/greenlight/test.rb', line 8 def name @name end |
Instance Method Details
#error_msg ⇒ Object
37 38 39 |
# File 'lib/greenlight/test.rb', line 37 def error_msg "TEST '#{name}' failed" end |
#run(args = {}) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/greenlight/test.rb', line 17 def run(args = {}) action Colors.white("TEST ") + Colors.yellow(name) Console.instance.indent begin ret = Greenlight.eval(args, &body) success('test succeeded') ret rescue RequestException error error_msg raise TestException rescue StandardError => e error e.backtrace.inspect error e. error error_msg raise TestException ensure Console.instance.unindent end end |