Module: IRT::Directives::Test
Instance Method Summary collapse
- #_eql?(saved) ⇒ Boolean (also: #test_value_eql?, #last_value_eql?)
- #_yaml_eql?(saved) ⇒ Boolean (also: #last_yaml_eql?, #test_yaml_eql?)
- #desc(description) ⇒ Object
- #load_helper_files ⇒ Object
- #reset_variables ⇒ Object
-
#test_summary ⇒ Object
:nodoc:.
Instance Method Details
#_eql?(saved) ⇒ Boolean Also known as: test_value_eql?, last_value_eql?
19 20 21 22 |
# File 'lib/irt/directives/test.rb', line 19 def _eql?(saved) actual = IRB.CurrentContext.last_value run_test(saved, actual, :value) end |
#_yaml_eql?(saved) ⇒ Boolean Also known as: last_yaml_eql?, test_yaml_eql?
26 27 28 29 |
# File 'lib/irt/directives/test.rb', line 26 def _yaml_eql?(saved) actual = IRT.yaml_dump(IRB.CurrentContext.last_value) run_test(saved, actual, :yaml) end |
#desc(description) ⇒ Object
15 16 17 |
# File 'lib/irt/directives/test.rb', line 15 def desc(description) @@last_desc = description end |
#load_helper_files ⇒ Object
46 47 48 49 50 51 52 53 54 |
# File 'lib/irt/directives/test.rb', line 46 def load_helper_files return unless IRT.autoload_helper_files container_path = Pathname.getwd.parent down_path = IRT.irt_file.relative_path_from container_path down_path.dirname.descend do |p| helper_path = container_path.join(p, 'irt_helper.rb') require helper_path if File.exist?(helper_path) end end |
#reset_variables ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/irt/directives/test.rb', line 6 def reset_variables @@tests = 0 @@oks = 0 @@diffs = 0 @@errors = 0 @@last_desc = nil end |
#test_summary ⇒ Object
:nodoc:
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/irt/directives/test.rb', line 33 def test_summary #:nodoc: return unless @@tests > 0 if @@tests == @@oks str = @@tests == 1 ? " The TEST is OK! " : " All #{@@tests} TESTs are OK! " puts IRT.dye(str, :ok_color, :bold) else puts IRT.dye("#{@@tests} TEST#{'s' unless @@tests == 1}: ", :bold) + IRT.dye("#{@@oks} OK#{'s' unless @@oks == 1}, ", :ok_color, :bold) + IRT.dye("#{@@diffs} DIFF#{'s' unless @@diffs == 1}, ", :diff_color, :bold) + IRT.dye("#{@@errors} ERROR#{'s' unless @@errors == 1}.", :error_color, :bold) end end |