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
61 62 63 64 65 66 67 68 69 |
# File 'lib/assert/view_helpers.rb', line 61 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
32 33 34 35 36 |
# File 'lib/assert/view_helpers.rb', line 32 def captured_output(output) "--- stdout ---\n"\ "#{output}"\ "--------------" end |
#re_run_test_cmd(test_id) ⇒ Object
show any captured output
39 40 41 |
# File 'lib/assert/view_helpers.rb', line 39 def re_run_test_cmd(test_id) "assert -t #{test_id.gsub(Dir.pwd, '.')}" end |
#result_count_statement ⇒ Object
47 48 49 |
# File 'lib/assert/view_helpers.rb', line 47 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
72 73 74 75 76 77 78 |
# File 'lib/assert/view_helpers.rb', line 72 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
82 83 84 85 86 87 88 |
# File 'lib/assert/view_helpers.rb', line 82 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
43 44 45 |
# File 'lib/assert/view_helpers.rb', line 43 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
52 53 54 55 56 57 58 |
# File 'lib/assert/view_helpers.rb', line 52 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 |