test_bench-fixture 1.2.2.2 → 1.2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 -12
- data/lib/test_bench/fixture/controls/test_file.rb +6 -1
- data/lib/test_bench/fixture/fixture.rb +4 -4
- data/lib/test_bench/fixture/session.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 92a9ac5353665c67bc88fb3c636eb9379f8a7b8f8cfd648ad9caa8d63765e12d
|
4
|
+
data.tar.gz: 782ae920e5d292b2f972deaa757537a77a4f63df1e35c38a8650af31205e0bcd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df910d453578e8c1b156386740d48141f326b72539decc9666094056d80db2f27deeae3a380433d8ef03968e8701e0e05545d796ff7376d38bdc1c314d368e45
|
7
|
+
data.tar.gz: 321c9d1b5b92e6572ac356dd518cfe481b9ae2b3f8df0b5b4197130a2123963e98aa73ce00e2e9b8d048dd9e0eaf29c172b0c398f19bcd8b2d7a4e92224ec778
|
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
|
@@ -53,9 +51,7 @@ module TestBench
|
|
53
51
|
file ||= self.file
|
54
52
|
line_number ||= self.line_number
|
55
53
|
|
56
|
-
|
57
|
-
proc { Thread.current.backtrace_locations[1] }.call
|
58
|
-
RUBY
|
54
|
+
TOPLEVEL_BINDING.receiver.instance_eval 'proc { caller[0] }.call', file, line_number
|
59
55
|
end
|
60
56
|
|
61
57
|
def self.file
|
@@ -65,6 +61,10 @@ module TestBench
|
|
65
61
|
def self.line_number
|
66
62
|
22
|
67
63
|
end
|
64
|
+
|
65
|
+
def self.label
|
66
|
+
'block in <main>'
|
67
|
+
end
|
68
68
|
end
|
69
69
|
end
|
70
70
|
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
|
@@ -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
|
|
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.2.
|
4
|
+
version: 1.2.3.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-08-
|
11
|
+
date: 2020-08-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: test_bench-bootstrap
|