cutest 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/cutest.gemspec +1 -1
  2. data/lib/cutest.rb +10 -6
  3. data/test/run.rb +2 -2
  4. metadata +2 -6
data/cutest.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "cutest"
3
- s.version = "0.1.4"
3
+ s.version = "0.1.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"]
data/lib/cutest.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require "batch"
2
2
 
3
3
  class Cutest < Batch
4
- VERSION = "0.1.4"
4
+ VERSION = "0.1.5"
5
5
 
6
6
  def report_error(_, error)
7
7
  $stderr.puts "#{error}\n"
@@ -17,11 +17,15 @@ class Cutest < Batch
17
17
  begin
18
18
  load(file, anonymous)
19
19
 
20
+ rescue Cutest::AssertionFailed => e
21
+ write.puts e.message
22
+
20
23
  rescue Exception => e
21
- error = [e.message] +
22
- e.backtrace.take_while { |line| !line.index(__FILE__) }
24
+ error = [e.message]
25
+ error += e.backtrace.take_while { |line| !line.index(__FILE__) }
26
+
27
+ write.puts ">> #{cutest[:test]}"
23
28
  write.puts error.join("\n")
24
- write.close
25
29
  end
26
30
  end
27
31
 
@@ -108,7 +112,7 @@ private
108
112
  # inside test blocks), it is necessary to wrap them in test blocks in order to
109
113
  # execute preparation and setup blocks.
110
114
  def test(name = nil, &block)
111
- @_test = name
115
+ cutest[:test] = name
112
116
 
113
117
  prepare.each { |blk| blk.call }
114
118
  block.call(setup && setup.call)
@@ -134,7 +138,7 @@ private
134
138
  def flunk
135
139
  file, line = caller[1].split(":")
136
140
  code = File.readlines(file)[line.to_i - 1]
137
- msg = ">> #{@_test}\n=> #{code.strip}\n #{file} +#{line}"
141
+ msg = ">> #{cutest[:test]}\n=> #{code.strip}\n #{file} +#{line}"
138
142
 
139
143
  raise Cutest::AssertionFailed.new(msg)
140
144
  end
data/test/run.rb CHANGED
@@ -47,7 +47,7 @@ test "output of failed run on an exception" do
47
47
  end
48
48
 
49
49
  assert stdout == " 0% E\n100% \n"
50
- assert stderr["\nSome errors occured:\n\nOops\n"]
50
+ assert stderr["\nSome errors occured:\n\n>> some unhandled exception\nOops\n"]
51
51
  assert stderr["test/fixtures/exception.rb:2:in `foo'\n"]
52
- assert stderr["test/fixtures/exception.rb:6:in `block in <top (required)>'\n\n"]
52
+ assert stderr["test/fixtures/exception.rb:6"]
53
53
  end
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cutest
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
5
4
  prerelease: false
6
5
  segments:
7
6
  - 0
8
7
  - 1
9
- - 4
10
- version: 0.1.4
8
+ - 5
9
+ version: 0.1.5
11
10
  platform: ruby
12
11
  authors:
13
12
  - Damian Janowski
@@ -27,7 +26,6 @@ dependencies:
27
26
  requirements:
28
27
  - - ~>
29
28
  - !ruby/object:Gem::Version
30
- hash: 25
31
29
  segments:
32
30
  - 0
33
31
  - 0
@@ -72,7 +70,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
72
70
  requirements:
73
71
  - - ">="
74
72
  - !ruby/object:Gem::Version
75
- hash: 3
76
73
  segments:
77
74
  - 0
78
75
  version: "0"
@@ -81,7 +78,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
81
78
  requirements:
82
79
  - - ">="
83
80
  - !ruby/object:Gem::Version
84
- hash: 3
85
81
  segments:
86
82
  - 0
87
83
  version: "0"