cutest-cj 1.6.4 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/cutest.rb +16 -2
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 855911385a297fbaf8e43d15b829d6d622961100
4
- data.tar.gz: c164ba12a0049bbb212dad54ebd7f705f6a55101
3
+ metadata.gz: 0b82e6938d5650a90190748359cca83ed52f1f52
4
+ data.tar.gz: 4e236fa33bba4f0c42803d9831e1bb7e6f533edc
5
5
  SHA512:
6
- metadata.gz: 02add321d4d012d65432b6452d20d36e8218b43b9929414b96662ecb0631edee0ca99f2c5d4e93879d4170e3899bca86b63fa353e65913d6bee48d72aaf2fdd1
7
- data.tar.gz: 34ab94b4c2ee5735924ad59f41312e2bdb6c0e4e9796528b52d90d459b8951338c350a1adf07b09aa66617bd625b951513500c73edd197be743643dd7e1e25bb
6
+ metadata.gz: 770fb54483a9d5e230ab9143aead6d5b960423615f27d7abebe0891c4cfd6934f968be76d85281d4e476865b8e2942e741b9618e475fcfb8508a09b7cd5c9625
7
+ data.tar.gz: 393bd14d01d5639e1e75582dc94fb1a3facf19b33d0ad6a9949a61ed74ff6e9db75cad780917345c05d14d298d42998b6e7a9fe30c84f88c1007e51785d9db21
@@ -7,7 +7,7 @@ class Cutest
7
7
  autoload :Database, 'cutest/database'
8
8
 
9
9
  unless defined?(VERSION)
10
- VERSION = "1.6.4"
10
+ VERSION = "1.7.0"
11
11
  FILTER = %r[/(ruby|jruby|rbx)[-/]([0-9\.])+]
12
12
  CACHE = Hash.new { |h, k| h[k] = File.readlines(k) }
13
13
  end
@@ -169,7 +169,7 @@ module Kernel
169
169
 
170
170
  # Use Thread.current[:cutest] to store information about test preparation
171
171
  # and setup.
172
- Thread.current[:cutest] ||= { :prepare => [] }
172
+ Thread.current[:cutest] ||= { :prepare => [], :before => [], :after => [] }
173
173
 
174
174
  # Shortcut to access Thread.current[:cutest].
175
175
  def cutest
@@ -196,6 +196,18 @@ module Kernel
196
196
  cutest[:prepare]
197
197
  end
198
198
 
199
+ # Unlike prepare this gets evaled before each test
200
+ def before(&block)
201
+ cutest[:before] << block if block_given?
202
+ cutest[:before]
203
+ end
204
+
205
+ # Unlike prepare this gets evaled after each test
206
+ def before(&block)
207
+ cutest[:after] << block if block_given?
208
+ cutest[:after]
209
+ end
210
+
199
211
  # Setup parameters for the tests. The block passed to setup is evaluated
200
212
  # before running each test, and the result of the setup block is passed to
201
213
  # the test as a parameter. If the setup and the tests are declared at the
@@ -253,7 +265,9 @@ module Kernel
253
265
  print ' '
254
266
  time_taken = Benchmark.measure do
255
267
  prepare.each { |blk| blk.call }
268
+ before.each { |blk| self.instance_eval blk }
256
269
  block.call(setup && self.instance_eval(&setup))
270
+ after.each { |blk| self.instance_eval blk }
257
271
  end
258
272
  puts ''
259
273
  puts " \033[93mTest: \033[0m#{cutest[:test]} \033[32m✔\033[0m"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cutest-cj
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.4
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Damian Janowski
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-08-01 00:00:00.000000000 Z
13
+ date: 2014-08-16 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: pry