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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 13a777ff52df4352c49326e6b394828cd64eed0abfdf54a0a677bff3f3958737
4
- data.tar.gz: ccaa7603572eec663dcf2638b5345af7c245ed0aaf137cac124a24e800775910
3
+ metadata.gz: 92a9ac5353665c67bc88fb3c636eb9379f8a7b8f8cfd648ad9caa8d63765e12d
4
+ data.tar.gz: 782ae920e5d292b2f972deaa757537a77a4f63df1e35c38a8650af31205e0bcd
5
5
  SHA512:
6
- metadata.gz: 4694182ab91a9e75de0f6c69c59bd027842989f075bb0787b15be6e2b4a092d4405943e3c91e1b7f242d1575132f9e3a268544809c201f16f817230d266aacee
7
- data.tar.gz: edc04eee7d348c8e2ea6216200e17eea95c6beee183ce45346542452bbce7f8da6a8dd06d87a4f3213825f7c44694fd43b5469ccdb698c141fd94ae1e11e9612
6
+ metadata.gz: df910d453578e8c1b156386740d48141f326b72539decc9666094056d80db2f27deeae3a380433d8ef03968e8701e0e05545d796ff7376d38bdc1c314d368e45
7
+ data.tar.gz: 321c9d1b5b92e6572ac356dd518cfe481b9ae2b3f8df0b5b4197130a2123963e98aa73ce00e2e9b8d048dd9e0eaf29c172b0c398f19bcd8b2d7a4e92224ec778
@@ -1,5 +1,7 @@
1
- require 'logger'
2
- require 'stringio'
1
+ unless RUBY_ENGINE == 'mruby'
2
+ require 'logger'
3
+ require 'stringio'
4
+ end
3
5
 
4
6
  require 'test_bench/fixture/assertion_failure'
5
7
 
@@ -2,7 +2,7 @@ module TestBench
2
2
  module Fixture
3
3
  class AssertionFailure < RuntimeError
4
4
  def self.build(caller_location=nil)
5
- caller_location ||= caller_locations.first
5
+ caller_location ||= caller[0]
6
6
 
7
7
  backtrace = [caller_location.to_s]
8
8
 
@@ -1,4 +1,6 @@
1
- require 'tempfile'
1
+ unless RUBY_ENGINE == 'mruby'
2
+ require 'tempfile'
3
+ end
2
4
 
3
5
  require 'test_bench/fixture/controls/caller_location'
4
6
  require 'test_bench/fixture/controls/error/backtrace'
@@ -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
- eval(<<~RUBY, TOPLEVEL_BINDING, file, line_number - 2)
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
- eval <<~RUBY, TOPLEVEL_BINDING, file, line_number
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 ||= caller_locations.first
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 ||= caller_locations.first
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 ||= caller_locations.first
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 ||= caller_locations.first
125
+ caller_location ||= caller[0]
126
126
 
127
127
  detail "Prohibited Error: #{error_class}#{' (strict)' if strict}"
128
128
 
@@ -114,7 +114,7 @@ module TestBench
114
114
  end
115
115
 
116
116
  def assert(value, caller_location: nil)
117
- caller_location ||= caller_locations.first
117
+ caller_location ||= caller[0]
118
118
 
119
119
  result = value ? true : false
120
120
 
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.2.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-08 00:00:00.000000000 Z
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