micro_test 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/micro_test.rb +54 -0
- metadata +49 -0
data/lib/micro_test.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
class MicroTest
|
2
|
+
class << self
|
3
|
+
def inherited(subclass)
|
4
|
+
@subclasses ||= []
|
5
|
+
@subclasses << subclass
|
6
|
+
end
|
7
|
+
|
8
|
+
attr_accessor :passed, :failed
|
9
|
+
|
10
|
+
def reset
|
11
|
+
@passed = 0
|
12
|
+
@failed = 0
|
13
|
+
end
|
14
|
+
|
15
|
+
def tests
|
16
|
+
@tests ||= {}
|
17
|
+
end
|
18
|
+
|
19
|
+
def run_tests
|
20
|
+
reset
|
21
|
+
@subclasses.each do |subclass|
|
22
|
+
puts subclass.name
|
23
|
+
subclass.tests.each do |desc, block|
|
24
|
+
puts " Test #{desc}: "
|
25
|
+
block.call
|
26
|
+
end
|
27
|
+
end
|
28
|
+
puts "Passed Asserts: \e[32m#{MicroTest.passed}\e[0m, Failed Asserts: \e[31m#{MicroTest.failed}\e[0m"
|
29
|
+
end
|
30
|
+
|
31
|
+
def test(description, &block)
|
32
|
+
tests[description] = block
|
33
|
+
end
|
34
|
+
|
35
|
+
def assert(value)
|
36
|
+
if value
|
37
|
+
MicroTest.passed += 1
|
38
|
+
puts " \e[32mPASS\e[0m: #{caller[0]}"
|
39
|
+
else
|
40
|
+
MicroTest.failed += 1
|
41
|
+
puts " \e[31mFAIL\e[0m: #{caller[0]}"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
# class ExampleTest < MicroTest
|
48
|
+
# test "booleans" do
|
49
|
+
# assert true
|
50
|
+
# assert false
|
51
|
+
# end
|
52
|
+
# end
|
53
|
+
|
54
|
+
# MicroTest.run_tests
|
metadata
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: micro_test
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Nathan Hopkins
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-09-24 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: ! ' A testing "framework" in 45 lines.
|
15
|
+
|
16
|
+
'
|
17
|
+
email:
|
18
|
+
- natehop@gmail.com
|
19
|
+
executables: []
|
20
|
+
extensions: []
|
21
|
+
extra_rdoc_files: []
|
22
|
+
files:
|
23
|
+
- lib/micro_test.rb
|
24
|
+
homepage: https://github.com/hopsoft/micro_test
|
25
|
+
licenses:
|
26
|
+
- MIT
|
27
|
+
post_install_message:
|
28
|
+
rdoc_options: []
|
29
|
+
require_paths:
|
30
|
+
- lib
|
31
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
32
|
+
none: false
|
33
|
+
requirements:
|
34
|
+
- - ! '>='
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '0'
|
37
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
38
|
+
none: false
|
39
|
+
requirements:
|
40
|
+
- - ! '>='
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
43
|
+
requirements: []
|
44
|
+
rubyforge_project:
|
45
|
+
rubygems_version: 1.8.24
|
46
|
+
signing_key:
|
47
|
+
specification_version: 3
|
48
|
+
summary: A tiny testing script.
|
49
|
+
test_files: []
|