minitest-suite_callbacks 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/minitest/suite_callbacks.rb +63 -0
- metadata +45 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3a8179e88e90edd230281e82dd434e3d4408b3c3
|
4
|
+
data.tar.gz: b272d88b7a19a3d7371660dec2e77e71570186be
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 325840ce50324be88cc50596d8b0b7d8e0cea15547295c049711d9415f68ec72e7a8daff86d08be33d3652d3cc9b9368b6061d979af8af4c3d22136feb4bf5e6
|
7
|
+
data.tar.gz: 66e13b0d486a2b5a6c974c2925a7e2a701c81c61c07b9e741a593c37361f06fbd168bb5235507a2fd300277b46d5660f1c0c7da6cff4efd358342ad682e83036
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# TODO: Make it work when we have a base level
|
2
|
+
# before_suite and a context/describe
|
3
|
+
#
|
4
|
+
# It just doesn't work at all with contexts & suite-wide setup
|
5
|
+
module Minitest::SuiteCallbacks
|
6
|
+
def self.extended(base)
|
7
|
+
base.class_eval do
|
8
|
+
class << self
|
9
|
+
attr_reader :sandbox
|
10
|
+
|
11
|
+
# DSL method
|
12
|
+
def before_suite(&before_suite_proc)
|
13
|
+
@before_suite_proc = before_suite_proc
|
14
|
+
# Setup state before suite
|
15
|
+
context = self
|
16
|
+
original_singleton_run = method(:run)
|
17
|
+
define_singleton_method :run do |*args, &block|
|
18
|
+
context.setup_before_suite
|
19
|
+
original_singleton_run.call(*args, &block)
|
20
|
+
end
|
21
|
+
|
22
|
+
# TODO what if we call before_suite multiple times?
|
23
|
+
original_instance_run = instance_method(:run)
|
24
|
+
define_method :run do |*args, &block|
|
25
|
+
context.transfer_sandbox_state_to(self)
|
26
|
+
original_instance_run.bind(self).call(*args, &block)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def after_suite(&after_suite_proc)
|
31
|
+
context = self
|
32
|
+
original_singleton_run = method(:run)
|
33
|
+
define_singleton_method :run do |*args, &block|
|
34
|
+
original_singleton_run.call(*args, &block)
|
35
|
+
context.sandbox.instance_eval &after_suite_proc
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def setup_before_suite
|
40
|
+
@sandbox = new('sandbox')
|
41
|
+
@sandbox.instance_eval &@before_suite_proc
|
42
|
+
end
|
43
|
+
|
44
|
+
def transfer_sandbox_state_to(dest_context)
|
45
|
+
# TODO: generate these
|
46
|
+
ivs_to_skip = [:@NAME, :@assertions, :@failures]
|
47
|
+
iv_map = {}
|
48
|
+
@sandbox.instance_variables.each do |iv|
|
49
|
+
next if ivs_to_skip.include?(iv)
|
50
|
+
iv_map[iv] = @sandbox.instance_variable_get(iv.to_sym)
|
51
|
+
end
|
52
|
+
|
53
|
+
dest_context.instance_eval do
|
54
|
+
iv_map.each do |k, v|
|
55
|
+
instance_variable_set k, v
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
metadata
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: minitest-suite_callbacks
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- backupify
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-12-30 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: before_suite and after_suite callbacks for Minitest
|
14
|
+
email: jb3689@yahoo.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/minitest/suite_callbacks.rb
|
20
|
+
homepage: https://github.com/backupify/minitest-suite_callbacks
|
21
|
+
licenses:
|
22
|
+
- MIT
|
23
|
+
metadata: {}
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
requirements: []
|
39
|
+
rubyforge_project:
|
40
|
+
rubygems_version: 2.2.2
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: before/after suites for Minitest
|
44
|
+
test_files: []
|
45
|
+
has_rdoc:
|