Module: Test

Defined in:
lib/pretty_debug.rb

Class Method Summary collapse

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),
		[$!.message, *PrettyDebug.clean($@).align(":")].map{|l| l.indent.color(:red)}
end

.testeeObject



152
# File 'lib/pretty_debug.rb', line 152

def self.testee; @@testee end

.testee_clearObject



158
# File 'lib/pretty_debug.rb', line 158

def self.testee_clear; @@testee = [] end

.testee_referObject



159
# File 'lib/pretty_debug.rb', line 159

def self.testee_refer; @@testee end