micro_test 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/micro_test.rb +42 -30
- metadata +2 -2
data/lib/micro_test.rb
CHANGED
@@ -1,54 +1,66 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
module MicroTest
|
2
|
+
module Runner
|
3
|
+
|
4
|
+
def self.red(text)
|
5
|
+
"\e[31m#{text}\e[0m"
|
6
6
|
end
|
7
7
|
|
8
|
-
|
8
|
+
def self.green(text)
|
9
|
+
"\e[32m#{text}\e[0m"
|
10
|
+
end
|
9
11
|
|
10
|
-
def
|
11
|
-
@
|
12
|
-
@failed = 0
|
12
|
+
def self.test_classes
|
13
|
+
@test_classes ||= []
|
13
14
|
end
|
14
15
|
|
15
|
-
def
|
16
|
-
|
16
|
+
def self.log(value)
|
17
|
+
if value
|
18
|
+
puts " #{green :PASS} #{caller[1]}"
|
19
|
+
@passed += 1
|
20
|
+
else
|
21
|
+
puts " #{red :FAIL} #{caller[1]}"
|
22
|
+
@failed += 1
|
23
|
+
end
|
17
24
|
end
|
18
25
|
|
19
|
-
def
|
20
|
-
|
21
|
-
|
22
|
-
puts
|
23
|
-
|
24
|
-
puts "
|
26
|
+
def self.run
|
27
|
+
@passed = @failed = 0
|
28
|
+
test_classes.each do |test_class|
|
29
|
+
puts test_class.name
|
30
|
+
test_class.tests.each do |desc, block|
|
31
|
+
puts "- test #{desc}: "
|
25
32
|
block.call
|
26
33
|
end
|
27
34
|
end
|
28
|
-
puts "Passed Asserts:
|
35
|
+
puts "Passed Asserts: #{green @passed}, Failed Asserts: #{red @failed}"
|
29
36
|
end
|
37
|
+
end
|
30
38
|
|
31
|
-
|
32
|
-
|
39
|
+
class Test
|
40
|
+
def self.inherited(subclass)
|
41
|
+
MicroTest::Runner.test_classes << subclass
|
33
42
|
end
|
34
43
|
|
35
|
-
def
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
44
|
+
def self.tests
|
45
|
+
@tests ||= {}
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.test(desc, &block)
|
49
|
+
tests[desc] = block
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.assert(value)
|
53
|
+
MicroTest::Runner.log(value)
|
43
54
|
end
|
44
55
|
end
|
45
56
|
end
|
46
57
|
|
47
|
-
# class ExampleTest < MicroTest
|
58
|
+
# class ExampleTest < MicroTest::Test
|
48
59
|
# test "booleans" do
|
49
60
|
# assert true
|
61
|
+
# assert true
|
50
62
|
# assert false
|
51
63
|
# end
|
52
64
|
# end
|
53
65
|
|
54
|
-
# MicroTest.
|
66
|
+
# MicroTest::Runner.run
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: micro_test
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ bindir: bin
|
|
11
11
|
cert_chain: []
|
12
12
|
date: 2012-09-24 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
|
-
description: ! ' A testing "framework"
|
14
|
+
description: ! ' A micro testing "framework".
|
15
15
|
|
16
16
|
'
|
17
17
|
email:
|