Module: RIO::Assert
- Defined in:
- lib/rio/assert.rb
Overview
:nodoc: all
Instance Method Summary collapse
- #assert(a, msg = nil) ⇒ Object
- #assert_block(msg = nil) ⇒ Object
- #assert_case_equal(a, b, msg = nil) ⇒ Object
- #assert_equal(a, b, msg = nil) ⇒ Object
- #assert_equal_a(a, b, msg = nil) ⇒ Object
- #assert_equal_s(a, b, msg = nil) ⇒ Object
- #assert_kind_of(a, b, msg = nil) ⇒ Object
- #assert_match(a, b, msg = nil) ⇒ Object
- #assert_nil(a, msg = nil) ⇒ Object
- #assert_not_equal(a, b, msg = nil) ⇒ Object
- #assert_same(a, b, msg = nil) ⇒ Object
- #nok(a, b, msg = nil) ⇒ Object
- #ok(a, b, msg = nil) ⇒ Object
Instance Method Details
#assert(a, msg = nil) ⇒ Object
51 52 53 |
# File 'lib/rio/assert.rb', line 51 def assert(a,msg=nil) assert_equal(true,a,msg) end |
#assert_block(msg = nil) ⇒ Object
68 69 70 71 72 73 74 |
# File 'lib/rio/assert.rb', line 68 def assert_block(msg=nil) if yield ok(nil,nil,msg) else nok(nil,nil,msg) end end |
#assert_case_equal(a, b, msg = nil) ⇒ Object
61 62 63 64 65 66 67 |
# File 'lib/rio/assert.rb', line 61 def assert_case_equal(a,b,msg=nil) if a == b ok(a,b,msg) else nok(a,b,msg) end end |
#assert_equal(a, b, msg = nil) ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/rio/assert.rb', line 54 def assert_equal(a,b,msg=nil) if a == b ok(a,b,msg) else nok(a,b,msg) end end |
#assert_equal_a(a, b, msg = nil) ⇒ Object
112 |
# File 'lib/rio/assert.rb', line 112 def assert_equal_a(a,b,msg=nil) assert_equal(a.sort,b.sort,msg) end |
#assert_equal_s(a, b, msg = nil) ⇒ Object
111 |
# File 'lib/rio/assert.rb', line 111 def assert_equal_s(a,b,msg=nil) assert_equal(a.to_s,b.to_s,msg) end |
#assert_kind_of(a, b, msg = nil) ⇒ Object
104 105 106 107 108 109 110 |
# File 'lib/rio/assert.rb', line 104 def assert_kind_of(a,b,msg=nil) if b.kind_of?(a) ok(a,b.class) else nok(a,b.class) end end |
#assert_match(a, b, msg = nil) ⇒ Object
97 98 99 100 101 102 103 |
# File 'lib/rio/assert.rb', line 97 def assert_match(a,b,msg=nil) if a =~ b ok(a,b) else nok(a,b) end end |
#assert_nil(a, msg = nil) ⇒ Object
83 84 85 86 87 88 89 |
# File 'lib/rio/assert.rb', line 83 def assert_nil(a,msg=nil) if a.nil? ok(nil,a) else nok(nil,a) end end |
#assert_not_equal(a, b, msg = nil) ⇒ Object
76 77 78 79 80 81 82 |
# File 'lib/rio/assert.rb', line 76 def assert_not_equal(a,b,msg=nil) if a != b ok(a,b,msg) else nok(a,b,msg) end end |
#assert_same(a, b, msg = nil) ⇒ Object
90 91 92 93 94 95 96 |
# File 'lib/rio/assert.rb', line 90 def assert_same(a,b,msg=nil) if a.equal? b ok(a,b) else nok(a,b) end end |
#nok(a, b, msg = nil) ⇒ Object
45 46 47 48 49 |
# File 'lib/rio/assert.rb', line 45 def nok(a,b,msg=nil) puts "FAIL" + (msg.nil? ? "" : ": #{msg}") puts " exp: #{a.inspect}" puts " was: #{b.inspect}" end |
#ok(a, b, msg = nil) ⇒ Object
42 43 44 |
# File 'lib/rio/assert.rb', line 42 def ok(a,b,msg=nil) puts "PASS" + (msg.nil? ? "" : ": #{msg}") end |