test_bench-fixture 1.2.2.1 → 1.3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/test_bench/fixture.rb +4 -2
- data/lib/test_bench/fixture/assertion_failure.rb +1 -1
- data/lib/test_bench/fixture/controls.rb +3 -1
- data/lib/test_bench/fixture/controls/caller_location.rb +12 -18
- data/lib/test_bench/fixture/controls/test_file.rb +6 -1
- data/lib/test_bench/fixture/error_policy.rb +1 -1
- data/lib/test_bench/fixture/fixture.rb +14 -6
- data/lib/test_bench/fixture/output/log.rb +1 -1
- data/lib/test_bench/fixture/session.rb +13 -10
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1646c13fe187bfe974852ada39082f6c6c156ed07bb973ffd20a11bec89afeb8
|
4
|
+
data.tar.gz: 13e67e83debb64b591e41162ee430f85b7a78ebea43d9d1d07020fcefbacd168
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 31f6de1bcb03d338e53e0c0c55e26546f4d82bca0fd7a019419a8f5a6ed188070d00d900ba99b20611cb6256a03351670894860dad744f1800817b9c9154ce47
|
7
|
+
data.tar.gz: 6863a84298362604a007ffaa9bd9f3b682afdeac8c27fca1a4765fb0451aa084eb642124a9c164d31d08f82f7ae50dcb1e9e71cd1504ffd983fefef551b4a2b4
|
data/lib/test_bench/fixture.rb
CHANGED
@@ -2,18 +2,12 @@ module TestBench
|
|
2
2
|
module Fixture
|
3
3
|
module Controls
|
4
4
|
module CallerLocation
|
5
|
-
def self.example(file: nil, line_number: nil)
|
5
|
+
def self.example(file: nil, line_number: nil, label: nil)
|
6
6
|
file ||= self.file
|
7
7
|
line_number ||= self.line_number
|
8
|
+
label ||= self.label
|
8
9
|
|
9
|
-
|
10
|
-
some_class = Class.new do
|
11
|
-
def self.some_method
|
12
|
-
Thread.current.backtrace_locations[1]
|
13
|
-
end
|
14
|
-
end
|
15
|
-
some_class.some_method
|
16
|
-
RUBY
|
10
|
+
"#{file}:#{line_number}:in `#{label}'"
|
17
11
|
end
|
18
12
|
|
19
13
|
def self.file
|
@@ -24,6 +18,10 @@ module TestBench
|
|
24
18
|
11
|
25
19
|
end
|
26
20
|
|
21
|
+
def self.label
|
22
|
+
'some_method'
|
23
|
+
end
|
24
|
+
|
27
25
|
module Alternate
|
28
26
|
def self.example(line_number: nil)
|
29
27
|
line_number ||= self.line_number
|
@@ -38,12 +36,6 @@ module TestBench
|
|
38
36
|
def self.line_number
|
39
37
|
111
|
40
38
|
end
|
41
|
-
|
42
|
-
module Pattern
|
43
|
-
def self.example
|
44
|
-
/other_dir/
|
45
|
-
end
|
46
|
-
end
|
47
39
|
end
|
48
40
|
|
49
41
|
Implementation = self
|
@@ -53,9 +45,7 @@ module TestBench
|
|
53
45
|
file ||= self.file
|
54
46
|
line_number ||= self.line_number
|
55
47
|
|
56
|
-
|
57
|
-
proc { Thread.current.backtrace_locations[1] }.call
|
58
|
-
RUBY
|
48
|
+
TOPLEVEL_BINDING.receiver.instance_eval 'proc { caller[0] }.call', file, line_number
|
59
49
|
end
|
60
50
|
|
61
51
|
def self.file
|
@@ -65,6 +55,10 @@ module TestBench
|
|
65
55
|
def self.line_number
|
66
56
|
22
|
67
57
|
end
|
58
|
+
|
59
|
+
def self.label
|
60
|
+
'block in <main>'
|
61
|
+
end
|
68
62
|
end
|
69
63
|
end
|
70
64
|
end
|
@@ -4,7 +4,8 @@ module TestBench
|
|
4
4
|
module TestFile
|
5
5
|
def self.example(filename: nil, text: nil, directory: nil)
|
6
6
|
filename ||= self.filename
|
7
|
-
text ||= text
|
7
|
+
text ||= self.text
|
8
|
+
directory ||= self.directory
|
8
9
|
|
9
10
|
basename, extension, _ = filename.partition('.rb')
|
10
11
|
|
@@ -29,6 +30,10 @@ module TestBench
|
|
29
30
|
'# Nothing'
|
30
31
|
end
|
31
32
|
|
33
|
+
def self.directory
|
34
|
+
'/tmp'
|
35
|
+
end
|
36
|
+
|
32
37
|
def self.tempfiles
|
33
38
|
@tempfiles ||= []
|
34
39
|
end
|
@@ -24,7 +24,7 @@ module TestBench
|
|
24
24
|
policies.fetch(policy) do
|
25
25
|
*policies, final_policy = self.policies.keys
|
26
26
|
|
27
|
-
policy_list = "#{policies.map(&:inspect)
|
27
|
+
policy_list = "#{policies.map(&:inspect).join(', ')} or #{final_policy.inspect}"
|
28
28
|
|
29
29
|
raise PolicyError, "Policy #{policy.inspect} is unknown. It must be one of: #{policy_list}"
|
30
30
|
end
|
@@ -58,22 +58,30 @@ module TestBench
|
|
58
58
|
alias_method :session, :test_session
|
59
59
|
alias_method :session=, :test_session=
|
60
60
|
|
61
|
-
def comment(text)
|
61
|
+
def comment(text, *additional_lines)
|
62
62
|
test_session.comment(text)
|
63
|
+
|
64
|
+
additional_lines.each do |text|
|
65
|
+
test_session.comment(text)
|
66
|
+
end
|
63
67
|
end
|
64
68
|
|
65
|
-
def detail(text)
|
69
|
+
def detail(text, *additional_lines)
|
66
70
|
test_session.detail(text)
|
71
|
+
|
72
|
+
additional_lines.each do |text|
|
73
|
+
test_session.detail(text)
|
74
|
+
end
|
67
75
|
end
|
68
76
|
|
69
77
|
def assert(value, caller_location: nil)
|
70
|
-
caller_location ||=
|
78
|
+
caller_location ||= caller[0]
|
71
79
|
|
72
80
|
test_session.assert(value, caller_location: caller_location)
|
73
81
|
end
|
74
82
|
|
75
83
|
def refute(value, caller_location: nil)
|
76
|
-
caller_location ||=
|
84
|
+
caller_location ||= caller[0]
|
77
85
|
|
78
86
|
test_session.assert(!value, caller_location: caller_location)
|
79
87
|
end
|
@@ -86,7 +94,7 @@ module TestBench
|
|
86
94
|
strict = true if strict.nil?
|
87
95
|
end
|
88
96
|
|
89
|
-
caller_location ||=
|
97
|
+
caller_location ||= caller[0]
|
90
98
|
|
91
99
|
detail "Expected Error: #{error_class}#{' (strict)' if strict}"
|
92
100
|
detail "Expected Message: #{message.inspect}" unless message.nil?
|
@@ -122,7 +130,7 @@ module TestBench
|
|
122
130
|
strict = true if strict.nil?
|
123
131
|
end
|
124
132
|
|
125
|
-
caller_location ||=
|
133
|
+
caller_location ||= caller[0]
|
126
134
|
|
127
135
|
detail "Prohibited Error: #{error_class}#{' (strict)' if strict}"
|
128
136
|
|
@@ -59,7 +59,7 @@ module TestBench
|
|
59
59
|
|
60
60
|
def self.assure_level(level)
|
61
61
|
unless level_ordinals.key?(level)
|
62
|
-
raise Error, "Unknown log level #{level.inspect} (Valid levels: #{levels.map(&:inspect)
|
62
|
+
raise Error, "Unknown log level #{level.inspect} (Valid levels: #{levels.map(&:inspect).join(', ')})"
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
@@ -114,7 +114,7 @@ module TestBench
|
|
114
114
|
end
|
115
115
|
|
116
116
|
def assert(value, caller_location: nil)
|
117
|
-
caller_location ||=
|
117
|
+
caller_location ||= caller[0]
|
118
118
|
|
119
119
|
result = value ? true : false
|
120
120
|
|
@@ -135,13 +135,15 @@ module TestBench
|
|
135
135
|
def load(path)
|
136
136
|
output.enter_file(path)
|
137
137
|
|
138
|
-
|
138
|
+
result = false
|
139
139
|
|
140
|
-
|
140
|
+
Kernel.load(path)
|
141
141
|
|
142
|
-
|
142
|
+
result = true
|
143
143
|
|
144
|
-
|
144
|
+
ensure
|
145
|
+
|
146
|
+
output.exit_file(path, result)
|
145
147
|
end
|
146
148
|
|
147
149
|
def test(title=nil, &block)
|
@@ -198,9 +200,10 @@ module TestBench
|
|
198
200
|
output.start_fixture(fixture)
|
199
201
|
|
200
202
|
action = proc { actions.each(&:call) }
|
201
|
-
result = evaluate(action)
|
202
203
|
|
203
|
-
|
204
|
+
result = evaluate(action) do |result|
|
205
|
+
output.finish_fixture(fixture, result)
|
206
|
+
end
|
204
207
|
|
205
208
|
result
|
206
209
|
end
|
@@ -214,12 +217,12 @@ module TestBench
|
|
214
217
|
rescue => error
|
215
218
|
error(error)
|
216
219
|
|
217
|
-
|
218
|
-
current_exception = $!
|
220
|
+
error = nil
|
219
221
|
|
222
|
+
ensure
|
220
223
|
result = error_counter == previous_error_counter
|
221
224
|
|
222
|
-
block.(result,
|
225
|
+
block.(result, error) unless block.nil?
|
223
226
|
end
|
224
227
|
|
225
228
|
result
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: test_bench-fixture
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Ladd
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-09-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: test_bench-bootstrap
|
@@ -74,5 +74,5 @@ requirements: []
|
|
74
74
|
rubygems_version: 3.1.4
|
75
75
|
signing_key:
|
76
76
|
specification_version: 4
|
77
|
-
summary: Test object framework
|
77
|
+
summary: Test object framework for Ruby and MRuby
|
78
78
|
test_files: []
|