cutest 0.0.2 → 0.0.3
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/cutest.gemspec +2 -2
- data/lib/cutest.rb +15 -4
- data/test/assert.rb +9 -0
- data/test/assert_raise.rb +14 -0
- data/test/{a_test.rb → setup.rb} +2 -2
- metadata +6 -6
- data/test/b_test.rb +0 -3
- data/test/c_test.rb +0 -7
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.
|
3
|
+
s.version = "0.0.3"
|
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/
|
9
|
+
s.files = ["LICENSE", "README.markdown", "Rakefile", "lib/cutest.rb", "cutest.gemspec", "test/assert.rb", "test/assert_raise.rb", "test/setup.rb"]
|
10
10
|
s.add_dependency "batch", "~> 0.0.1"
|
11
11
|
end
|
data/lib/cutest.rb
CHANGED
@@ -1,17 +1,28 @@
|
|
1
1
|
require "batch"
|
2
2
|
|
3
|
-
AssertionFailed
|
3
|
+
class AssertionFailed < StandardError; end
|
4
4
|
|
5
5
|
def assert(value)
|
6
|
-
|
6
|
+
flunk unless value
|
7
|
+
end
|
8
|
+
|
9
|
+
def assert_raise(expected = Exception)
|
10
|
+
begin
|
11
|
+
yield
|
12
|
+
rescue => exception
|
13
|
+
ensure
|
14
|
+
flunk unless exception.kind_of?(expected)
|
15
|
+
end
|
16
|
+
end
|
7
17
|
|
18
|
+
def flunk(caller = caller[1])
|
8
19
|
ex = AssertionFailed.new(@_test)
|
9
20
|
ex.set_backtrace(caller)
|
10
21
|
|
11
22
|
file, line = ex.backtrace.shift.split(":")
|
12
23
|
code = File.readlines(file)[line.to_i - 1]
|
13
24
|
|
14
|
-
ex.message.replace("=> #{code.strip}\n#{file}
|
25
|
+
ex.message.replace(">> #{@_test}\n=> #{code.strip}\n #{file} +#{line}")
|
15
26
|
|
16
27
|
raise ex
|
17
28
|
end
|
@@ -28,7 +39,7 @@ def test(name = nil, &block)
|
|
28
39
|
end
|
29
40
|
|
30
41
|
class Cutest < Batch
|
31
|
-
VERSION = "0.0.
|
42
|
+
VERSION = "0.0.3"
|
32
43
|
|
33
44
|
def report_errors
|
34
45
|
return if @errors.empty?
|
data/test/assert.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
test "catches the right exception" do
|
2
|
+
assert_raise(RuntimeError) do
|
3
|
+
raise RuntimeError
|
4
|
+
end
|
5
|
+
end
|
6
|
+
|
7
|
+
|
8
|
+
test "raises if the expectation is not met" do
|
9
|
+
assert_raise(AssertionFailed) do
|
10
|
+
assert_raise(RuntimeError) do
|
11
|
+
raise ArgumentError
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/test/{a_test.rb → setup.rb}
RENAMED
@@ -6,10 +6,10 @@ test "should receive the result of the setup block as a parameter" do |params|
|
|
6
6
|
assert params == {:a => 23, :b => 43}
|
7
7
|
end
|
8
8
|
|
9
|
-
test "
|
9
|
+
test "if the params are modified..." do |params|
|
10
10
|
params[:a] = nil
|
11
11
|
end
|
12
12
|
|
13
|
-
test "should preserve the original values from the setup" do |params|
|
13
|
+
test "...it should preserve the original values from the setup" do |params|
|
14
14
|
assert 23 == params[:a]
|
15
15
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 3
|
9
|
+
version: 0.0.3
|
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-
|
18
|
+
date: 2010-09-13 00:00:00 -03:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -49,9 +49,9 @@ files:
|
|
49
49
|
- Rakefile
|
50
50
|
- lib/cutest.rb
|
51
51
|
- cutest.gemspec
|
52
|
-
- test/
|
53
|
-
- test/
|
54
|
-
- test/
|
52
|
+
- test/assert.rb
|
53
|
+
- test/assert_raise.rb
|
54
|
+
- test/setup.rb
|
55
55
|
has_rdoc: true
|
56
56
|
homepage: http://github.com/djanowski/cutest
|
57
57
|
licenses: []
|
data/test/b_test.rb
DELETED