rspec_trunk_flaky_tests 0.17.0.pre.beta.3-x86_64-linux-gnu → 0.17.0-x86_64-linux-gnu

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: 3655817f6cf9bdac7d6d0ccfb7cd4574c9e34a17c6d7d020e4f66a511cc2aedd
4
- data.tar.gz: fda4e01421dda7ff24d035c67dded82aad5c2ee7a8ef4e2ecd5c0b21003911bf
3
+ metadata.gz: f970360e2ce7de57cfea163cd268df75a33826787ca9575d820fa5f862649cbd
4
+ data.tar.gz: b95b7ee21a1ea18a3f62bdb161f4673b2fd89e88a24e731349c827f7e2925be9
5
5
  SHA512:
6
- metadata.gz: 3bd2fd995a0ce33e60c51b391e921fe139bbaafa468f065136e1f4ac95407dcaec6729716ec7dd0e606339d30c644be7cf3f1fcb5c86eced462e880fb6acde88
7
- data.tar.gz: '096c22df1f1084fe19b6ba098743ac5d2c64f3844a03c470778bf4501d9a0d4e8a24271f664b03fb42c96562d0ff7e723a46f12e877fbbbdf05daeb7d0c4dd4f'
6
+ metadata.gz: 55021abef14a796637e53943b6bf64db70bf5c57d6eef4ea6096220f43c992df90ee95c344349beed12dfea7a5c41fd27fc283d9285805a4b729c6b7ad2b7a25
7
+ data.tar.gz: 99eaf086a93a6afab2238510b7b54e32bb054280830b71f7c012e01fd7da94ab5d19f008b30d770275433ed0367aa2e39a4f71089844da0a2e6f4595348fcfc0
@@ -46,6 +46,15 @@ module RSpec
46
46
  module Trunk
47
47
  ANSI_ESCAPE_PATTERN = %r{(?:\e[@-Z\\-_]|\e\[[0-?]*[ -/]*[@-~])}
48
48
 
49
+ CORE_METHODS = {
50
+ name: [Module.instance_method(:name), String],
51
+ class: [Kernel.instance_method(:class), Module]
52
+ }.freeze
53
+ CLASS_SUPERCLASS = Class.instance_method(:superclass)
54
+ KERNEL_IS_A = Kernel.instance_method(:is_a?)
55
+ MODULE_TO_S = Module.instance_method(:to_s)
56
+ MEMORY_ADDRESS = /:0x\h+>/
57
+
49
58
  # Knapsack example detector instantiates all test cases in order to determine how to shard them
50
59
  # These instantiations should not generate test bundles, so we
51
60
  # disable the gem when running under knapsack_pro:rspec_test_example_detector
@@ -186,21 +195,51 @@ module RSpec
186
195
  end
187
196
 
188
197
  def description_arg(arg)
189
- if arg.is_a?(Module)
190
- arg.name || anonymous_module_name(arg)
198
+ if core_is_a?(arg, Module)
199
+ module_description(arg, arg.to_s)
191
200
  elsif default_to_s?(arg)
192
- "#<#{arg.class.name || anonymous_module_name(arg.class)}>"
201
+ klass = core_call(arg, :class)
202
+ "#<#{module_description(klass, MODULE_TO_S.bind_call(klass))}>"
193
203
  else
194
204
  arg.to_s
195
205
  end
196
206
  end
197
207
 
198
208
  def anonymous_module_name(mod)
199
- return '#<Module>' unless mod.is_a?(Class)
209
+ return '#<Module>' unless core_is_a?(mod, Class)
210
+
211
+ superclass = CLASS_SUPERCLASS.bind_call(mod)
212
+ superclass = CLASS_SUPERCLASS.bind_call(superclass) while superclass && module_name(superclass).nil?
213
+ superclass ? "#<Class < #{module_name(superclass)}>" : '#<Class>'
214
+ end
215
+
216
+ # `described` is the module's #to_s, which is RSpec's (and so 0.16.1's) name for it,
217
+ # kept unless it has an address in it.
218
+ def module_description(mod, described)
219
+ return described unless MEMORY_ADDRESS.match?(described)
220
+
221
+ name = module_name(mod)
222
+ name.nil? || name.empty? ? anonymous_module_name(mod) : name
223
+ end
200
224
 
201
- superclass = mod.superclass
202
- superclass = superclass.superclass while superclass && superclass.name.nil?
203
- superclass ? "#<Class < #{superclass.name}>" : '#<Class>'
225
+ def module_name(mod)
226
+ core_call(mod, :name)
227
+ end
228
+
229
+ # The arg's own method when it works as core's does, else core's: a class may define
230
+ # .name for something else (private, or taking arguments).
231
+ def core_call(obj, method_name)
232
+ core, type = CORE_METHODS.fetch(method_name)
233
+ value = obj.public_send(method_name)
234
+ value.is_a?(type) ? value : core.bind_call(obj)
235
+ rescue StandardError, NotImplementedError
236
+ core.bind_call(obj)
237
+ end
238
+
239
+ def core_is_a?(obj, type)
240
+ KERNEL_IS_A.bind_call(obj, type)
241
+ rescue TypeError # a BasicObject
242
+ false
204
243
  end
205
244
 
206
245
  # Kernel's method, so an object whose own #method means something else
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec_trunk_flaky_tests
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.0.pre.beta.3
4
+ version: 0.17.0
5
5
  platform: x86_64-linux-gnu
6
6
  authors:
7
7
  - Trunk Technologies, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-11-09 00:00:00.000000000 Z
11
+ date: 2026-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec-core