Module: BasicTest
- Extended by:
- BasicTest
- Included in:
- BasicTest
- Defined in:
- lib/basic_test.rb,
lib/basic_test/version.rb
Constant Summary collapse
- VERSION =
"0.4.0"
Instance Method Summary collapse
- #capture_stderr(&blk) ⇒ Object
- #capture_stdout(&blk) ⇒ Object
- #display_results(expected, actual) ⇒ Object
- #test(string, expected, actual) ⇒ Object
Instance Method Details
#capture_stderr(&blk) ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/basic_test.rb', line 34 def capture_stderr(&blk) old = $stderr $stderr = fake = StringIO.new blk.call fake.string ensure $stderr = old end |
#capture_stdout(&blk) ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/basic_test.rb', line 25 def capture_stdout(&blk) old = $stdout $stdout = fake = StringIO.new blk.call fake.string ensure $stdout = old end |
#display_results(expected, actual) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/basic_test.rb', line 13 def display_results(expected, actual) result = (expected == actual) if result puts "PASS" else puts "Expected: #{expected}".red puts "Actual: #{actual}".red puts "FAIL".red end puts "----------------------------------" end |
#test(string, expected, actual) ⇒ Object
8 9 10 11 |
# File 'lib/basic_test.rb', line 8 def test(string, expected, actual) puts string display_results(expected, actual) end |