Module: Test::More
- Defined in:
- lib/test/more.rb
Instance Method Summary collapse
- #BAIL_OUT(reason) ⇒ Object
- #can_ok(method, label) ⇒ Object
- #cmp_ok(got, want, label) ⇒ Object
- #diag(msg) ⇒ Object
- #done_testing(count = nil) ⇒ Object
- #eq_array(got, label) ⇒ Object
- #eq_hash(got, label) ⇒ Object
- #eq_set(got, label) ⇒ Object
- #explain(msg) ⇒ Object
- #failed(label) ⇒ Object
- #is(got, want, label) ⇒ Object
- #is_deeply(got, want, label) ⇒ Object
- #isa_ok(class_, label) ⇒ Object
- #isnt(got, dont, label) ⇒ Object
- #like(got, regex, label) ⇒ Object
- #new_ok(class_, label) ⇒ Object
- #note(msg) ⇒ Object
- #ok(got, label) ⇒ Object
- #pass(label) ⇒ Object
- #plan(cmd, arg) ⇒ Object
- #require_ok(library, label) ⇒ Object
- #skip(reason) ⇒ Object
- #subtest(label, callback) ⇒ Object
- #todo(label) ⇒ Object
- #todo_skip(got, want, label) ⇒ Object
- #unlike(got, regex, label) ⇒ Object
- #use_ok(library, label) ⇒ Object
Instance Method Details
#BAIL_OUT(reason) ⇒ Object
169 170 171 |
# File 'lib/test/more.rb', line 169 def BAIL_OUT reason fail "Test::More##{__method__.to_s} not yet implemented" end |
#can_ok(method, label) ⇒ Object
135 136 137 |
# File 'lib/test/more.rb', line 135 def can_ok method, label fail "Test::More##{__method__.to_s} not yet implemented" end |
#cmp_ok(got, want, label) ⇒ Object
63 64 65 |
# File 'lib/test/more.rb', line 63 def cmp_ok got, want, label fail "Test::More##{__method__.to_s} not yet implemented" end |
#diag(msg) ⇒ Object
147 148 149 150 151 152 |
# File 'lib/test/more.rb', line 147 def diag msg fail unless msg msg.gsub! /\n/, "\n# " $stderr.puts "# #{msg}" $stderr.flush end |
#done_testing(count = nil) ⇒ Object
129 130 131 132 133 |
# File 'lib/test/more.rb', line 129 def done_testing count=nil count ||= $test_more.run puts "1..#{count}" $stdout.flush end |
#eq_array(got, label) ⇒ Object
101 102 103 |
# File 'lib/test/more.rb', line 101 def eq_array got, label fail "Test::More##{__method__.to_s} not yet implemented" end |
#eq_hash(got, label) ⇒ Object
105 106 107 |
# File 'lib/test/more.rb', line 105 def eq_hash got, label fail "Test::More##{__method__.to_s} not yet implemented" end |
#eq_set(got, label) ⇒ Object
109 110 111 |
# File 'lib/test/more.rb', line 109 def eq_set got, label fail "Test::More##{__method__.to_s} not yet implemented" end |
#explain(msg) ⇒ Object
161 162 163 |
# File 'lib/test/more.rb', line 161 def explain msg fail "Test::More##{__method__.to_s} not yet implemented" end |
#failed(label) ⇒ Object
90 91 92 93 94 95 96 97 98 99 |
# File 'lib/test/more.rb', line 90 def failed label $test_more.run_incr $test_more.failed_incr if ! label.empty? puts "not ok #{$test_more.run} - #{label}" else puts "not ok #{$test_more.run}" end $stdout.flush end |
#is(got, want, label) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/test/more.rb', line 19 def is got, want, label if got.to_s == want.to_s pass label else failed label diag "\ got: '#{got}' expected: '#{want}'" end end |
#is_deeply(got, want, label) ⇒ Object
59 60 61 |
# File 'lib/test/more.rb', line 59 def is_deeply got, want, label fail "Test::More##{__method__.to_s} not yet implemented" end |
#isa_ok(class_, label) ⇒ Object
139 140 141 |
# File 'lib/test/more.rb', line 139 def isa_ok class_, label fail "Test::More##{__method__.to_s} not yet implemented" end |
#isnt(got, dont, label) ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/test/more.rb', line 30 def isnt got, dont, label if got.to_s != want.to_s pass label else failed label diag "\ got: '#{got}' expected: anything else" end end |
#like(got, regex, label) ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/test/more.rb', line 41 def like got, regex, label if got =~ regex pass label else failed label diag "Got: '#{got}'" end end |
#new_ok(class_, label) ⇒ Object
143 144 145 |
# File 'lib/test/more.rb', line 143 def new_ok class_, label fail "Test::More##{__method__.to_s} not yet implemented" end |
#note(msg) ⇒ Object
154 155 156 157 158 159 |
# File 'lib/test/more.rb', line 154 def note msg fail unless msg msg.gsub! /\n/, "\n# " puts "# #{msg}" $stdout.flush end |
#ok(got, label) ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/test/more.rb', line 3 def ok got, label if got pass label else failed label end end |
#pass(label) ⇒ Object
79 80 81 82 83 84 85 86 87 88 |
# File 'lib/test/more.rb', line 79 def pass label $test_more.run_incr if ! label.empty? puts "ok #{$test_more.run} - #{label}" $stderr.flush else puts "ok #{$test_more.run}" end $stdout.flush end |
#plan(cmd, arg) ⇒ Object
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/test/more.rb', line 113 def plan cmd, arg fail 'Usage: plan tests <number>' unless cmd and arg if cmd == 'tests' fail 'Plan must be a number' unless arg.to_s =~ /^-?[0-9]+$/ fail 'Plan must greater then 0' unless arg > 0 $test_more.plan = arg puts "1..#{$test_more.plan}" elsif cmd == 'skip_all' puts "1..0 # SKIP #{arg}" exit 0 else fail 'Usage: plan tests <number>' end $stdout.flush end |
#require_ok(library, label) ⇒ Object
15 16 17 |
# File 'lib/test/more.rb', line 15 def require_ok library, label fail "Test::More##{__method__.to_s} not yet implemented" end |
#skip(reason) ⇒ Object
67 68 69 |
# File 'lib/test/more.rb', line 67 def skip reason fail "Test::More##{__method__.to_s} not yet implemented" end |
#subtest(label, callback) ⇒ Object
165 166 167 |
# File 'lib/test/more.rb', line 165 def subtest label, callback fail "Test::More##{__method__.to_s} not yet implemented" end |
#todo(label) ⇒ Object
71 72 73 |
# File 'lib/test/more.rb', line 71 def todo label fail "Test::More##{__method__.to_s} not yet implemented" end |
#todo_skip(got, want, label) ⇒ Object
75 76 77 |
# File 'lib/test/more.rb', line 75 def todo_skip got, want, label fail "Test::More##{__method__.to_s} not yet implemented" end |
#unlike(got, regex, label) ⇒ Object
50 51 52 53 54 55 56 57 |
# File 'lib/test/more.rb', line 50 def unlike got, regex, label if got !~ regex pass label else failed label diag "Got: '#{got}'" end end |
#use_ok(library, label) ⇒ Object
11 12 13 |
# File 'lib/test/more.rb', line 11 def use_ok library, label fail "Test::More##{__method__.to_s} not yet implemented" end |