Module: Test
- Defined in:
- lib/pretty_debug.rb
Class Method Summary collapse
- .raise?(exception = Exception, &pr) ⇒ Boolean
- .test(title = "Test", &pr) ⇒ Object
- .testee ⇒ Object
- .testee_clear ⇒ Object
- .testee_refer ⇒ Object
Class Method Details
.raise?(exception = Exception, &pr) ⇒ Boolean
153 154 155 156 157 |
# File 'lib/pretty_debug.rb', line 153 def self.raise? exception = Exception, &pr pr.call; false rescue Exception => e e.kind_of?(exception) end |
.test(title = "Test", &pr) ⇒ Object
160 161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/pretty_debug.rb', line 160 def self.test title = "Test", &pr testee_clear t = Time.now if pr.call == true puts "#{title}. Succeeded (#{"%.2e" % t.till_now} secs)".color(:green) else puts "#{title}. Failed".color(:red), *(testee_refer.map{|o| o.inspect.indent.color(:red)} unless testee_refer.empty?) end rescue Exception puts "#{title} ... Test Error".color(:red), [$!., *PrettyDebug.clean($@).align(":")].map{|l| l.indent.color(:red)} end |
.testee ⇒ Object
152 |
# File 'lib/pretty_debug.rb', line 152 def self.testee; @@testee end |
.testee_clear ⇒ Object
158 |
# File 'lib/pretty_debug.rb', line 158 def self.testee_clear; @@testee = [] end |
.testee_refer ⇒ Object
159 |
# File 'lib/pretty_debug.rb', line 159 def self.testee_refer; @@testee end |