test_bench-fixture 1.2.1.1 → 1.3.0.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/error.rb +6 -1
- 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 +4 -4
- data/lib/test_bench/fixture/output/capture.rb +20 -2
- data/lib/test_bench/fixture/output/log.rb +1 -1
- data/lib/test_bench/fixture/session.rb +4 -4
- 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: 94d72f2d00cb5ba026c616661faa24565ab70cd91213e4ecfb3ca9c981ad49a3
|
4
|
+
data.tar.gz: babd50bac0a5c05c070ea38de7b42e48daa2a15230dc164a16a935ad924640c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 87ba393d75101f74c03fa8ff9aae87b6e5b3c4a5741b60be1d3661b3e604d9cdd0de36f54c4c05ca5599cb7961484b69279b8801a3d010990758d8c2fcb7c8bd
|
7
|
+
data.tar.gz: d3ca9bd2c20c31a37b831025b00aba88a5a130e25a67f2fd733dc0b17df7b1f865fcf92dc16b77c13683742140534e587f439c580e590eac7a988eca5e29db9b
|
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
|
@@ -5,7 +5,12 @@ module TestBench
|
|
5
5
|
def self.example(message=nil, backtrace: nil, backtrace_depth: nil, cause: nil, cls: nil)
|
6
6
|
message ||= self.message
|
7
7
|
cls ||= Example
|
8
|
-
|
8
|
+
|
9
|
+
if backtrace == :none
|
10
|
+
backtrace = []
|
11
|
+
else
|
12
|
+
backtrace ||= Backtrace.example(depth: backtrace_depth)
|
13
|
+
end
|
9
14
|
|
10
15
|
if cause == true
|
11
16
|
cause = Cause.example
|
@@ -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
|
@@ -67,13 +67,13 @@ module TestBench
|
|
67
67
|
end
|
68
68
|
|
69
69
|
def assert(value, caller_location: nil)
|
70
|
-
caller_location ||=
|
70
|
+
caller_location ||= caller[0]
|
71
71
|
|
72
72
|
test_session.assert(value, caller_location: caller_location)
|
73
73
|
end
|
74
74
|
|
75
75
|
def refute(value, caller_location: nil)
|
76
|
-
caller_location ||=
|
76
|
+
caller_location ||= caller[0]
|
77
77
|
|
78
78
|
test_session.assert(!value, caller_location: caller_location)
|
79
79
|
end
|
@@ -86,7 +86,7 @@ module TestBench
|
|
86
86
|
strict = true if strict.nil?
|
87
87
|
end
|
88
88
|
|
89
|
-
caller_location ||=
|
89
|
+
caller_location ||= caller[0]
|
90
90
|
|
91
91
|
detail "Expected Error: #{error_class}#{' (strict)' if strict}"
|
92
92
|
detail "Expected Message: #{message.inspect}" unless message.nil?
|
@@ -122,7 +122,7 @@ module TestBench
|
|
122
122
|
strict = true if strict.nil?
|
123
123
|
end
|
124
124
|
|
125
|
-
caller_location ||=
|
125
|
+
caller_location ||= caller[0]
|
126
126
|
|
127
127
|
detail "Prohibited Error: #{error_class}#{' (strict)' if strict}"
|
128
128
|
|
@@ -99,13 +99,31 @@ module TestBench
|
|
99
99
|
def new_record(signal, data)
|
100
100
|
context = current_context.dup
|
101
101
|
|
102
|
-
record = Record.
|
102
|
+
record = Record.build(signal, data, context)
|
103
103
|
end
|
104
104
|
|
105
|
-
Record
|
105
|
+
class Record
|
106
|
+
attr_accessor :signal
|
107
|
+
attr_accessor :data
|
108
|
+
attr_accessor :context
|
109
|
+
|
110
|
+
def self.build(signal, data, context=nil)
|
111
|
+
instance = new
|
112
|
+
instance.signal = signal
|
113
|
+
instance.data = data
|
114
|
+
instance.context = context
|
115
|
+
instance
|
116
|
+
end
|
117
|
+
|
106
118
|
def forward(receiver)
|
107
119
|
receiver.public_send(signal, *data)
|
108
120
|
end
|
121
|
+
|
122
|
+
def ==(record)
|
123
|
+
self.signal == record.signal &&
|
124
|
+
self.data == record.data &&
|
125
|
+
self.context == record.context
|
126
|
+
end
|
109
127
|
end
|
110
128
|
end
|
111
129
|
end
|
@@ -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
|
|
@@ -214,12 +214,12 @@ module TestBench
|
|
214
214
|
rescue => error
|
215
215
|
error(error)
|
216
216
|
|
217
|
-
|
218
|
-
current_exception = $!
|
217
|
+
error = nil
|
219
218
|
|
219
|
+
ensure
|
220
220
|
result = error_counter == previous_error_counter
|
221
221
|
|
222
|
-
block.(result,
|
222
|
+
block.(result, error) unless block.nil?
|
223
223
|
end
|
224
224
|
|
225
225
|
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.0.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-08-11 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: []
|