assert(false, "statement is true")
produces output (to stdout, by default) containing the descriptive message "statement is true". What if I want the output to also contain the descriptive message for assertions that pass, i.e. if I instead have assert(true, "statement is true")
, is there an easy way to get it to send to stdout something along the lines of "asserting 'statement is true'... OK"?
Asked
Active
Viewed 62 times
0

gcbenison
- 11,723
- 4
- 44
- 82
-
why not [`refute`](http://ruby-doc.org/stdlib-2.0.0/libdoc/minitest/rdoc/MiniTest/Assertions.html#method-i-refute) ? – Arup Rakshit Jun 19 '14 at 19:21
2 Answers
1
You have to manually print your message, you can define your own assertion or helper method. Try:
def assert_with_message(condition, message)
assert condition
puts message
end
and:
assert_with_message true, "Assertion success message"

Malik Shahzad
- 6,703
- 3
- 37
- 49
0
Sure, just try:
def assert_if(condition, message)
assert(!condition, message)
end
and now:
assert_if true, "statement is true"

John Feminella
- 303,634
- 46
- 339
- 357