Module: Assert::ViewHelpers::InstanceMethods
- Defined in:
- lib/assert/view_helpers.rb
Instance Method Summary collapse
-
#all_pass_result_summary_msg ⇒ Object
generate an appropriate result summary msg for all tests passing.
-
#captured_output(output) ⇒ Object
show any captured output.
-
#re_run_test_cmd(test_id) ⇒ Object
show any captured output.
- #result_count_statement ⇒ Object
-
#result_summary_msg(result_type) ⇒ Object
print a result summary message for a given result type.
-
#results_summary_sentence ⇒ Object
generate a sentence fragment describing the breakdown of test results if a block is given, yield each msg in the breakdown for custom formatting.
- #tests_to_run_count_statement ⇒ Object
-
#to_sentence(items) ⇒ Object
generate a comma-seperated sentence fragment given a list of items.
Instance Method Details
#all_pass_result_summary_msg ⇒ Object
generate an appropriate result summary msg for all tests passing
56 57 58 59 60 61 62 63 64 |
# File 'lib/assert/view_helpers.rb', line 56 def all_pass_result_summary_msg if self.result_count < 1 "uhh..." elsif self.result_count == 1 "pass" else "all pass" end end |
#captured_output(output) ⇒ Object
show any captured output
27 28 29 30 31 |
# File 'lib/assert/view_helpers.rb', line 27 def captured_output(output) "--- stdout ---\n"\ "#{output}"\ "--------------" end |
#re_run_test_cmd(test_id) ⇒ Object
show any captured output
34 35 36 |
# File 'lib/assert/view_helpers.rb', line 34 def re_run_test_cmd(test_id) "assert -t #{test_id.gsub(Dir.pwd, ".")}" end |
#result_count_statement ⇒ Object
42 43 44 |
# File 'lib/assert/view_helpers.rb', line 42 def result_count_statement "#{self.result_count} result#{"s" if self.result_count != 1}" end |
#result_summary_msg(result_type) ⇒ Object
print a result summary message for a given result type
67 68 69 70 71 72 73 |
# File 'lib/assert/view_helpers.rb', line 67 def result_summary_msg(result_type) if result_type == :pass && self.all_pass? self.all_pass_result_summary_msg else "#{self.send("#{result_type}_result_count")} #{result_type}" end end |
#results_summary_sentence ⇒ Object
generate a sentence fragment describing the breakdown of test results if a block is given, yield each msg in the breakdown for custom formatting
77 78 79 80 81 82 83 |
# File 'lib/assert/view_helpers.rb', line 77 def results_summary_sentence summaries = self.ocurring_result_types.map do |result_type| summary_msg = self.result_summary_msg(result_type) block_given? ? yield(summary_msg, result_type) : summary_msg end self.to_sentence(summaries) end |
#tests_to_run_count_statement ⇒ Object
38 39 40 |
# File 'lib/assert/view_helpers.rb', line 38 def tests_to_run_count_statement "#{self.tests_to_run_count} test#{"s" if self.tests_to_run_count != 1}" end |
#to_sentence(items) ⇒ Object
generate a comma-seperated sentence fragment given a list of items
47 48 49 50 51 52 53 |
# File 'lib/assert/view_helpers.rb', line 47 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 |