contest 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -19,7 +19,7 @@ Declare your tests as you would in RSpec or Shoulda:
19
19
  setup do
20
20
  @value = 1
21
21
  end
22
-
22
+
23
23
  teardown do
24
24
  @value = nil
25
25
  end
@@ -78,8 +78,16 @@ Or with a regular expression:
78
78
  Installation
79
79
  ------------
80
80
 
81
- $ gem sources -a http://gems.github.com (you only have to do this once)
82
- $ sudo gem install citrusbyte-contest
81
+ $ sudo gem install contest
82
+
83
+ If you want to use it with Rails, add this to config/environment.rb:
84
+
85
+ config.gem "contest"
86
+
87
+ Then you can vendor the gem:
88
+
89
+ rake gems:install
90
+ rake gems:unpack
83
91
 
84
92
  License
85
93
  -------
@@ -33,7 +33,7 @@ class Test::Unit::TestCase
33
33
  def self.context(name, &block)
34
34
  subclass = Class.new(self)
35
35
  remove_tests(subclass)
36
- subclass.class_eval(&block)
36
+ subclass.class_eval(&block) if block_given?
37
37
  const_set(context_name(name), subclass)
38
38
  end
39
39
 
@@ -95,12 +95,20 @@ class TestBaz < Test::Unit::TestCase
95
95
  super
96
96
  @value += 2
97
97
  end
98
-
98
+
99
+ def bar
100
+ foo + 1
101
+ end
102
+
99
103
  test "a helper" do
100
104
  assert_equal 42, foo
101
105
  assert_equal 3, @value
102
106
  end
103
-
107
+
108
+ test "another helper" do
109
+ assert_equal 43, bar
110
+ end
111
+
104
112
  context "another context" do
105
113
  setup do
106
114
  @value += 3
@@ -111,4 +119,6 @@ class TestBaz < Test::Unit::TestCase
111
119
  end
112
120
  end
113
121
  end
122
+
123
+ context "empty context"
114
124
  end
@@ -0,0 +1,28 @@
1
+ require File.dirname(__FILE__) + "/../lib/contest"
2
+
3
+ class BaseTest < Test::Unit::TestCase
4
+ def setup
5
+ @order = []
6
+ @order << "Grandparent Setup"
7
+ end
8
+
9
+ def teardown
10
+ @order << "Grandparent Teardown"
11
+
12
+ assert_equal ["Grandparent Setup", "Parent Setup", "Child Setup", "Test Case", "Child Teardown", "Parent Teardown", "Grandparent Teardown"], @order
13
+ end
14
+ end
15
+
16
+ class MidLayerTest < BaseTest
17
+ setup { @order << "Parent Setup" }
18
+ teardown { @order << "Parent Teardown" }
19
+ end
20
+
21
+ class LeafTest < MidLayerTest
22
+ setup { @order << "Child Setup" }
23
+ teardown { @order << "Child Teardown" }
24
+
25
+ test "my actual test" do
26
+ @order << "Test Case"
27
+ end
28
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: contest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Damian Janowski
@@ -10,12 +10,14 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2009-03-16 00:00:00 -03:00
13
+ date: 2009-06-19 00:00:00 -03:00
14
14
  default_executable:
15
15
  dependencies: []
16
16
 
17
- description:
18
- email: damian.janowski@gmail.com
17
+ description: Write declarative tests using nested contexts without performance penalties. Contest is less than 100 lines of code and gets the job done.
18
+ email:
19
+ - djanowski@dimaion.com
20
+ - michel@soveran.com
19
21
  executables: []
20
22
 
21
23
  extensions: []
@@ -29,8 +31,8 @@ files:
29
31
  - Rakefile
30
32
  - rails/init.rb
31
33
  - test/all_test.rb
32
- - test/setup_and_teardown_order.rb
33
- has_rdoc: false
34
+ - test/setup_and_teardown_order_test.rb
35
+ has_rdoc: true
34
36
  homepage: http://github.com/citrusbyte/contest
35
37
  licenses: []
36
38
 
@@ -53,10 +55,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
53
55
  version:
54
56
  requirements: []
55
57
 
56
- rubyforge_project:
57
- rubygems_version: 1.3.2
58
+ rubyforge_project: contest
59
+ rubygems_version: 1.3.4
58
60
  signing_key:
59
- specification_version: 2
61
+ specification_version: 3
60
62
  summary: Write more readable tests in Test::Unit with this tiny script.
61
63
  test_files: []
62
64
 
@@ -1,27 +0,0 @@
1
- require File.dirname(__FILE__) + "/../lib/contest"
2
-
3
- class Test::Unit::TestCase
4
- def setup
5
- puts "Grandparent Setup"
6
- end
7
- end
8
-
9
- class Test::Unit::TestCase
10
- def teardown
11
- puts "Grandparent Teardown"
12
- end
13
- end
14
-
15
- class MidLayerTest < Test::Unit::TestCase
16
- setup { puts "Parent Setup" }
17
- teardown { puts "Parent Teardown" }
18
- end
19
-
20
- class LeafTest < MidLayerTest
21
- setup { puts "Child Setup" }
22
- teardown { puts "Child Teardown" }
23
-
24
- test "my actual test" do
25
- puts "Test Case"
26
- end
27
- end