minitest-utils 0.1.4 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 03a93deeaff791c6e0c463f3900a5ef73b2e9818
4
- data.tar.gz: 65399906d8d423813fd89de0a92f3f092761c75d
3
+ metadata.gz: 2e05b2ac23684f1e18f9041e435ffbb208e20298
4
+ data.tar.gz: 2fde7a6d2dc9aab27ea5bac439dc13351b8e0a36
5
5
  SHA512:
6
- metadata.gz: c372c13681dd4f4d9a371affa37fe1f67b8459de91a26b244c3efc32e480f5fdc30e7beca387eaab88be22b4f0ad8d9454c572320e326f4a87cfbd4c62773002
7
- data.tar.gz: b0669b26b8d42dc24728d9a7f802782c8ce90e40ebd9cb5f6d33e2b3e2258101e7424761e5adaeff7d501a04e6d85bb9e455b159fd0427961fd601b5392838a2
6
+ metadata.gz: 7408e2d383242fdbb7d2d9a5eb25cce5203fa2141f2e33368fc012116e2c771d8f01f33813d3246ef016ae7955b085de33a3d5c2a2d2783ba20d646536aa6fa0
7
+ data.tar.gz: cb472e1b97e50b6572a05144066ed647298442107b1165f09a5c8d5f5cb5c6205d032929048dd30f73159fde9e28170dc6c3ee1b8faf6e445940800ad37b5536
data/README.md CHANGED
@@ -39,6 +39,24 @@ end
39
39
 
40
40
  This is equivalent to defining a method named `test_useless_test`. You can also skip the block, which will define a [flunk](https://github.com/seattlerb/minitest/blob/77120c5b2511c4665610cda06c8058c801b28e7f/lib/minitest/assertions.rb#L477-L480) call.
41
41
 
42
+ You can also define `setup` and `teardown` steps.
43
+
44
+ ```ruby
45
+ class SampleTest < Minitest::Test
46
+ setup do
47
+ DB.connect
48
+ end
49
+
50
+ teardown do
51
+ DB.disconnect
52
+ end
53
+
54
+ test 'useless test' do
55
+ assert true
56
+ end
57
+ end
58
+ ```
59
+
42
60
  ## Screenshots
43
61
 
44
62
  ![](https://raw.githubusercontent.com/fnando/minitest-utils/master/screenshots/light-failing.png)
@@ -14,5 +14,29 @@ module Minitest
14
14
  end
15
15
  end
16
16
  end
17
+
18
+ def self.setup(&block)
19
+ mod = Module.new
20
+ mod.module_eval do
21
+ define_method :setup do
22
+ super()
23
+ instance_eval(&block)
24
+ end
25
+ end
26
+
27
+ include mod
28
+ end
29
+
30
+ def self.teardown(&block)
31
+ mod = Module.new
32
+ mod.module_eval do
33
+ define_method :teardown do
34
+ super()
35
+ instance_eval(&block)
36
+ end
37
+ end
38
+
39
+ include mod
40
+ end
17
41
  end
18
42
  end
@@ -142,7 +142,7 @@ module Minitest
142
142
 
143
143
  def color(string, color = :default)
144
144
  color = COLOR.fetch(color, 0)
145
- "\e[#{color}m#{string}"
145
+ "\e[#{color}m#{string}\e[0m"
146
146
  end
147
147
 
148
148
  def pluralize(word, count)
@@ -1,5 +1,5 @@
1
1
  module Minitest
2
2
  module Utils
3
- VERSION = '0.1.4'
3
+ VERSION = '0.2.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitest-utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nando Vieira
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-05-21 00:00:00.000000000 Z
11
+ date: 2015-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest