micro_test 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/test/math.rb +45 -0
- data/test/test_test.rb +47 -0
- metadata +3 -1
data/test/math.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# # /example/test/math_test.rb
|
2
|
+
# class MathTest < MicroTest::Test
|
3
|
+
|
4
|
+
# before :all do
|
5
|
+
# # puts "runs once before all tests"
|
6
|
+
# end
|
7
|
+
|
8
|
+
# before :each do
|
9
|
+
# # puts "runs before each test"
|
10
|
+
# end
|
11
|
+
|
12
|
+
# test "addition" do
|
13
|
+
# assert 2 + 2 == 4
|
14
|
+
# end
|
15
|
+
|
16
|
+
# test "subtraction" do
|
17
|
+
# assert 2 - 2 == 0
|
18
|
+
# end
|
19
|
+
|
20
|
+
# test "multiplication" do
|
21
|
+
# assert 2 * 2 == 4
|
22
|
+
# end
|
23
|
+
|
24
|
+
# test "division" do
|
25
|
+
# assert 2 / 2 == 1 # add a trailing comment if you want a message
|
26
|
+
# end
|
27
|
+
|
28
|
+
# # and one failing test
|
29
|
+
# test "fail" do
|
30
|
+
# assert 2 + 2 == 5
|
31
|
+
# end
|
32
|
+
|
33
|
+
# # test "error" do
|
34
|
+
# # assert 1 / 0 == 0
|
35
|
+
# # end
|
36
|
+
|
37
|
+
# after :each do
|
38
|
+
# # puts "runs after each test"
|
39
|
+
# end
|
40
|
+
|
41
|
+
# after :all do
|
42
|
+
# # puts "runs once after all tests"
|
43
|
+
# end
|
44
|
+
|
45
|
+
# end
|
data/test/test_test.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
class TestTest < MicroTest::Test
|
2
|
+
|
3
|
+
before :all do
|
4
|
+
@Test = Class.new(MicroTest::Test)
|
5
|
+
end
|
6
|
+
|
7
|
+
test "interface" do
|
8
|
+
assert @Test.respond_to?(:inherited)
|
9
|
+
assert @Test.respond_to?(:notify)
|
10
|
+
assert @Test.respond_to?(:callbacks)
|
11
|
+
assert @Test.respond_to?(:invoke)
|
12
|
+
assert @Test.respond_to?(:before)
|
13
|
+
assert @Test.respond_to?(:after)
|
14
|
+
assert @Test.respond_to?(:tests)
|
15
|
+
assert @Test.respond_to?(:test)
|
16
|
+
assert @Test.respond_to?(:assert)
|
17
|
+
end
|
18
|
+
|
19
|
+
test "callbacks data structure" do
|
20
|
+
assert @Test.callbacks.is_a?(Hash)
|
21
|
+
assert @Test.callbacks[:before].is_a?(Hash)
|
22
|
+
assert @Test.callbacks[:after].is_a?(Hash)
|
23
|
+
end
|
24
|
+
|
25
|
+
test "callbacks" do
|
26
|
+
a = lambda {}
|
27
|
+
b = lambda {}
|
28
|
+
c = lambda {}
|
29
|
+
d = lambda {}
|
30
|
+
@Test.before(:all, &a)
|
31
|
+
@Test.before(:each, &b)
|
32
|
+
@Test.after(:each, &c)
|
33
|
+
@Test.after(:all, &d)
|
34
|
+
assert @Test.callbacks[:before][:all].equal?(a)
|
35
|
+
assert @Test.callbacks[:before][:each].equal?(b)
|
36
|
+
assert @Test.callbacks[:after][:each].equal?(c)
|
37
|
+
assert @Test.callbacks[:after][:all].equal?(d)
|
38
|
+
end
|
39
|
+
|
40
|
+
test "failure" do
|
41
|
+
# Failing on purpose for the demo.
|
42
|
+
# Use pry to check out the current binding.
|
43
|
+
# For example, type @Test.
|
44
|
+
assert false
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
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.1.
|
4
|
+
version: 0.1.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -76,6 +76,8 @@ files:
|
|
76
76
|
- lib/micro_test/test.rb
|
77
77
|
- lib/micro_test.rb
|
78
78
|
- bin/mt
|
79
|
+
- test/math.rb
|
80
|
+
- test/test_test.rb
|
79
81
|
- Gemfile
|
80
82
|
- Gemfile.lock
|
81
83
|
- README.md
|