citrusbyte-contest 0.0.8 → 0.0.9
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/contest.rb +11 -6
- data/test/all_test.rb +1 -1
- data/test/setup_and_teardown_order.rb +23 -0
- metadata +2 -1
data/lib/contest.rb
CHANGED
@@ -25,15 +25,11 @@ class Test::Unit::TestCase
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def setup
|
28
|
-
self.class.
|
29
|
-
instance_eval(&block)
|
30
|
-
end
|
28
|
+
eval_blocks(:setup_blocks, self.class.ancestors.reverse)
|
31
29
|
end
|
32
30
|
|
33
31
|
def teardown
|
34
|
-
self.class.
|
35
|
-
instance_eval(&block)
|
36
|
-
end
|
32
|
+
eval_blocks(:teardown_blocks, self.class.ancestors)
|
37
33
|
end
|
38
34
|
|
39
35
|
def self.context(name, &block)
|
@@ -55,6 +51,15 @@ class Test::Unit::TestCase
|
|
55
51
|
|
56
52
|
private
|
57
53
|
|
54
|
+
def eval_blocks(type, ancestors)
|
55
|
+
ancestors.each do |ancestor|
|
56
|
+
next unless ancestor.respond_to?(type)
|
57
|
+
ancestor.send(type).each do |block|
|
58
|
+
instance_eval(&block)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
58
63
|
def self.setup_blocks
|
59
64
|
@setup_blocks ||= []
|
60
65
|
end
|
data/test/all_test.rb
CHANGED
@@ -0,0 +1,23 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../lib/contest"
|
2
|
+
|
3
|
+
class Test::Unit::TestCase
|
4
|
+
setup { puts "Grandparent Setup" }
|
5
|
+
end
|
6
|
+
|
7
|
+
class Test::Unit::TestCase
|
8
|
+
teardown { puts "Grandparent Teardown" }
|
9
|
+
end
|
10
|
+
|
11
|
+
class MidLayerTest < Test::Unit::TestCase
|
12
|
+
setup { puts "Parent Setup" }
|
13
|
+
teardown { puts "Parent Teardown" }
|
14
|
+
end
|
15
|
+
|
16
|
+
class LeafTest < MidLayerTest
|
17
|
+
setup { puts "Child Setup" }
|
18
|
+
teardown { puts "Child Teardown" }
|
19
|
+
|
20
|
+
test "my actual test" do
|
21
|
+
puts "Test Case"
|
22
|
+
end
|
23
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: citrusbyte-contest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Damian Janowski
|
@@ -29,6 +29,7 @@ files:
|
|
29
29
|
- Rakefile
|
30
30
|
- rails/init.rb
|
31
31
|
- test/all_test.rb
|
32
|
+
- test/setup_and_teardown_order.rb
|
32
33
|
has_rdoc: false
|
33
34
|
homepage: http://github.com/citrusbyte/contest
|
34
35
|
post_install_message:
|