cutest 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/cutest.gemspec CHANGED
@@ -1,11 +1,11 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "cutest"
3
- s.version = "0.0.4"
3
+ s.version = "0.0.5"
4
4
  s.summary = "Forking tests."
5
5
  s.description = "Run tests in separate processes to avoid shared state."
6
6
  s.authors = ["Damian Janowski", "Michel Martens"]
7
7
  s.email = ["djanowski@dimaion.com", "michel@soveran.com"]
8
8
  s.homepage = "http://github.com/djanowski/cutest"
9
- s.files = ["LICENSE", "README.markdown", "Rakefile", "lib/cutest.rb", "cutest.gemspec", "test/assert.rb", "test/assert_raise.rb", "test/setup.rb"]
9
+ s.files = ["LICENSE", "README.markdown", "Rakefile", "lib/cutest.rb", "cutest.gemspec", "test/assert.rb", "test/assert_raise.rb", "test/prepare.rb", "test/setup.rb"]
10
10
  s.add_dependency "batch", "~> 0.0.1"
11
11
  end
data/lib/cutest.rb CHANGED
@@ -27,6 +27,13 @@ def flunk(caller = caller[1])
27
27
  raise ex
28
28
  end
29
29
 
30
+ @_prepare = []
31
+
32
+ def prepare(&block)
33
+ @_prepare << block if block_given?
34
+ @_prepare
35
+ end
36
+
30
37
  @_setup = nil
31
38
 
32
39
  def setup(&block)
@@ -37,11 +44,12 @@ end
37
44
  def test(name = nil, &block)
38
45
  @_test = name
39
46
 
47
+ prepare.each { |block| block.call }
40
48
  block.call(setup && setup.call)
41
49
  end
42
50
 
43
51
  class Cutest < Batch
44
- VERSION = "0.0.4"
52
+ VERSION = "0.0.5"
45
53
 
46
54
  def report_errors
47
55
  return if @errors.empty?
data/test/prepare.rb ADDED
@@ -0,0 +1,19 @@
1
+ prepare do
2
+ @foo = []
3
+ end
4
+
5
+ prepare do
6
+ @foo << true
7
+ end
8
+
9
+ test "all the prepare blocks are called" do
10
+ assert @foo == [true]
11
+ end
12
+
13
+ prepare do
14
+ @foo << false
15
+ end
16
+
17
+ test "and are cumulative" do
18
+ assert @foo == [true, false]
19
+ end
data/test/setup.rb CHANGED
@@ -13,3 +13,11 @@ end
13
13
  test "...it should preserve the original values from the setup" do |params|
14
14
  assert 23 == params[:a]
15
15
  end
16
+
17
+ setup do
18
+ "Hello world!"
19
+ end
20
+
21
+ test "only the most recently defined setup block is executed" do |value|
22
+ assert "Hello world!" == value
23
+ end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 4
9
- version: 0.0.4
8
+ - 5
9
+ version: 0.0.5
10
10
  platform: ruby
11
11
  authors:
12
12
  - Damian Janowski
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-09-13 00:00:00 -03:00
18
+ date: 2010-09-15 00:00:00 -03:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -51,6 +51,7 @@ files:
51
51
  - cutest.gemspec
52
52
  - test/assert.rb
53
53
  - test/assert_raise.rb
54
+ - test/prepare.rb
54
55
  - test/setup.rb
55
56
  has_rdoc: true
56
57
  homepage: http://github.com/djanowski/cutest