test_bench-fixture 1.2.1.0 → 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: '0992f5e6c75342a4c1a00a5e7a073d0995c08793f1c98a57bef9a45bb48e5527'
4
- data.tar.gz: f5ccb333e7346b924fb6a722a3823e6dade82b436d1b7b3648646bf69d83f1fb
3
+ metadata.gz: 92a9ac5353665c67bc88fb3c636eb9379f8a7b8f8cfd648ad9caa8d63765e12d
4
+ data.tar.gz: 782ae920e5d292b2f972deaa757537a77a4f63df1e35c38a8650af31205e0bcd
5
5
  SHA512:
6
- metadata.gz: 2cfed2039a82439443f5e204b044bd064f00564405d6dccfffede0b0edd186a23c5923c7ab53cc984ee88804c7da192efac542ef769f802d63b8e47bacef8bf3
7
- data.tar.gz: 955beb3e2c19e12c17378922e1764e208904d92efee856e1113088549f9cd1013e0c0e7ef4f81a9eb1ed3ba22fd1f7d80dd90614ea96103d808e730c1a4e4923
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
@@ -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
- backtrace ||= Backtrace.example(depth: backtrace_depth)
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
@@ -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
 
@@ -99,13 +99,31 @@ module TestBench
99
99
  def new_record(signal, data)
100
100
  context = current_context.dup
101
101
 
102
- record = Record.new(signal, data, context)
102
+ record = Record.build(signal, data, context)
103
103
  end
104
104
 
105
- Record = Struct.new(:signal, :data, :context) do
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
@@ -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
 
@@ -214,12 +214,12 @@ module TestBench
214
214
  rescue => error
215
215
  error(error)
216
216
 
217
- ensure
218
- current_exception = $!
217
+ error = nil
219
218
 
219
+ ensure
220
220
  result = error_counter == previous_error_counter
221
221
 
222
- block.(result, current_exception) unless block.nil?
222
+ block.(result, error) unless block.nil?
223
223
  end
224
224
 
225
225
  result
@@ -10,6 +10,8 @@ module TestBench
10
10
  def scope(*contexts)
11
11
  scoped_output = output.scope(*contexts)
12
12
 
13
+ return nil if scoped_output.records.empty?
14
+
13
15
  scoped_session = self.class.new
14
16
  scoped_session.output = scoped_output
15
17
  scoped_session
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.1.0
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-07-24 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
@@ -71,7 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
71
71
  - !ruby/object:Gem::Version
72
72
  version: '0'
73
73
  requirements: []
74
- rubygems_version: 3.1.3
74
+ rubygems_version: 3.1.4
75
75
  signing_key:
76
76
  specification_version: 4
77
77
  summary: Test object framework