test_bench-fixture 1.2.2.2 → 1.3.1.1
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 +19 -7
- data/lib/test_bench/fixture/output/log.rb +1 -1
- data/lib/test_bench/fixture/session.rb +10 -7
- 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: 1d3be2a7cebd18fa06326859f2169a44e6a8974af8c32033669bbd95aacc827b
|
4
|
+
data.tar.gz: 36784decf899b9f0432da060ce1133d4e426a45830ce6adaf92c7c82e405f4d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a9d28986ecc5bd4c76efd955b7dcc6923289dbe8430fa849ba20e5340805dead1f0a1f3ed7813dd403041fbf3decb2bd2dcd27d72e195a3690cdf84d4abf4eed
|
7
|
+
data.tar.gz: 8d52b899330892b3e021ce3c275dc51573ea6c02995c704bab40d5698da21a5e934ab42e1ea81afdeb14b213dd19e295e9061901a2d2201173050d1c6b1679be
|
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
|
@@ -37,7 +37,11 @@ module TestBench
|
|
37
37
|
def self.call(cls, *args, **kwargs, &block)
|
38
38
|
factory_method = factory_method(cls)
|
39
39
|
|
40
|
-
|
40
|
+
if factory_method.name == :new
|
41
|
+
last_parameter_type, _ = cls.instance_method(:initialize).parameters.last
|
42
|
+
else
|
43
|
+
last_parameter_type, _ = factory_method.parameters.last
|
44
|
+
end
|
41
45
|
|
42
46
|
if last_parameter_type == :block
|
43
47
|
instance = build(cls, *args, **kwargs, &block)
|
@@ -58,22 +62,30 @@ module TestBench
|
|
58
62
|
alias_method :session, :test_session
|
59
63
|
alias_method :session=, :test_session=
|
60
64
|
|
61
|
-
def comment(text)
|
65
|
+
def comment(text, *additional_lines)
|
62
66
|
test_session.comment(text)
|
67
|
+
|
68
|
+
additional_lines.each do |text|
|
69
|
+
test_session.comment(text)
|
70
|
+
end
|
63
71
|
end
|
64
72
|
|
65
|
-
def detail(text)
|
73
|
+
def detail(text, *additional_lines)
|
66
74
|
test_session.detail(text)
|
75
|
+
|
76
|
+
additional_lines.each do |text|
|
77
|
+
test_session.detail(text)
|
78
|
+
end
|
67
79
|
end
|
68
80
|
|
69
81
|
def assert(value, caller_location: nil)
|
70
|
-
caller_location ||=
|
82
|
+
caller_location ||= caller[0]
|
71
83
|
|
72
84
|
test_session.assert(value, caller_location: caller_location)
|
73
85
|
end
|
74
86
|
|
75
87
|
def refute(value, caller_location: nil)
|
76
|
-
caller_location ||=
|
88
|
+
caller_location ||= caller[0]
|
77
89
|
|
78
90
|
test_session.assert(!value, caller_location: caller_location)
|
79
91
|
end
|
@@ -86,7 +98,7 @@ module TestBench
|
|
86
98
|
strict = true if strict.nil?
|
87
99
|
end
|
88
100
|
|
89
|
-
caller_location ||=
|
101
|
+
caller_location ||= caller[0]
|
90
102
|
|
91
103
|
detail "Expected Error: #{error_class}#{' (strict)' if strict}"
|
92
104
|
detail "Expected Message: #{message.inspect}" unless message.nil?
|
@@ -122,7 +134,7 @@ module TestBench
|
|
122
134
|
strict = true if strict.nil?
|
123
135
|
end
|
124
136
|
|
125
|
-
caller_location ||=
|
137
|
+
caller_location ||= caller[0]
|
126
138
|
|
127
139
|
detail "Prohibited Error: #{error_class}#{' (strict)' if strict}"
|
128
140
|
|
@@ -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
|
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.1
|
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-14 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: []
|