module Assert::ViewHelpers::InstanceMethods
Public Instance Methods
all_pass_result_summary_msg()
click to toggle source
generate an appropriate result summary msg for all tests passing
# File lib/assert/view_helpers.rb, line 58 def all_pass_result_summary_msg if result_count < 1 "uhh..." elsif result_count == 1 "pass" else "all pass" end end
captured_output(output)
click to toggle source
show any captured output
# File lib/assert/view_helpers.rb, line 29 def captured_output(output) "--- stdout ---\n"\ "#{output}"\ "--------------" end
re_run_test_cmd(test_id)
click to toggle source
show any captured output
# File lib/assert/view_helpers.rb, line 36 def re_run_test_cmd(test_id) "assert -t #{test_id.gsub(Dir.pwd, ".")}" end
result_count_statement()
click to toggle source
# File lib/assert/view_helpers.rb, line 44 def result_count_statement "#{result_count} result#{"s" if result_count != 1}" end
result_summary_msg(result_type)
click to toggle source
print a result summary message for a given result type
# File lib/assert/view_helpers.rb, line 69 def result_summary_msg(result_type) if result_type == :pass && all_pass? all_pass_result_summary_msg else "#{send("#{result_type}_result_count")} #{result_type}" end end
results_summary_sentence() { |summary_msg, result_type| ... }
click to toggle source
generate a sentence fragment describing the breakdown of test results if a block is given, yield each msg in the breakdown for custom formatting.
# File lib/assert/view_helpers.rb, line 80 def results_summary_sentence summaries = ocurring_result_types.map do |result_type| summary_msg = result_summary_msg(result_type) block_given? ? yield(summary_msg, result_type) : summary_msg end to_sentence(summaries) end
tests_to_run_count_statement()
click to toggle source
# File lib/assert/view_helpers.rb, line 40 def tests_to_run_count_statement "#{tests_to_run_count} test#{"s" if tests_to_run_count != 1}" end
to_sentence(items)
click to toggle source
generate a comma-seperated sentence fragment given a list of items
# File lib/assert/view_helpers.rb, line 49 def to_sentence(items) if items.size <= 2 items.join(items.size == 2 ? " and " : "") else [items[0..-2].join(", "), items.last].join(", and ") end end