Module: Sus::Output::Messages

Included in:
Null, Text
Defined in:
lib/sus/output/messages.rb

Constant Summary collapse

PASSED_PREFIX =
[:passed, ""].freeze
FAILED_PREFIX =
[:failed, ""].freeze

Instance Method Summary collapse

Instance Method Details

#assert(condition, orientation, message, backtrace) ⇒ Object

If the orientation is true, and the test passed, then it is a successful outcome. If the orientation is false, and the test failed, then it is a successful outcome. Otherwise, it is a failed outcome.



37
38
39
40
41
42
43
# File 'lib/sus/output/messages.rb', line 37

def assert(condition, orientation, message, backtrace)
	if condition
		self.puts(:indent, *pass_prefix(orientation), message, backtrace)
	else
		self.puts(:indent, *fail_prefix(orientation), message, backtrace)
	end
end

#error(error, identity, prefix = error_prefix) ⇒ Object



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/sus/output/messages.rb', line 57

def error(error, identity, prefix = error_prefix)
	lines = error.message.split(/\r?\n/)

	self.puts(:indent, *prefix, error.class, ": ", lines.shift)
	
	lines.each do |line|
		self.puts(:indent, line)
	end
		
	self.write(Output::Backtrace.for(error, identity))
	
	if cause = error.cause
		self.error(cause, identity, ["Caused by ", :errored])
	end
end

#error_prefixObject



53
54
55
# File 'lib/sus/output/messages.rb', line 53

def error_prefix
	[:errored, ""]
end

#fail_prefix(orientation) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/sus/output/messages.rb', line 21

def fail_prefix(orientation)
	if orientation
		FAILED_PREFIX
	else
		PASSED_PREFIX
	end
end

#inform(message, identity) ⇒ Object



77
78
79
# File 'lib/sus/output/messages.rb', line 77

def inform(message, identity)
	self.puts(:indent, :inform, inform_prefix, message)
end

#inform_prefixObject



73
74
75
# File 'lib/sus/output/messages.rb', line 73

def inform_prefix
	""
end

#pass_prefix(orientation) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/sus/output/messages.rb', line 13

def pass_prefix(orientation)
	if orientation
		PASSED_PREFIX
	else
		FAILED_PREFIX
	end
end

#skip(reason, identity) ⇒ Object



49
50
51
# File 'lib/sus/output/messages.rb', line 49

def skip(reason, identity)
	self.puts(:indent, :skipped, skip_prefix, reason)
end

#skip_prefixObject



45
46
47
# File 'lib/sus/output/messages.rb', line 45

def skip_prefix
	""
end