rspec_trunk_flaky_tests 0.16.3 → 0.17.0.pre.beta.1

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/trunk_spec_helper.rb +7 -46
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0feac8d56ad33b4a791829c4a5187101fc01f61cc94361dae76bd0e09cfdcd85
4
- data.tar.gz: b3f3febcc6d003a9a0674c9264f4435ace0230d7e73c84899c23e2dad7c6c3bb
3
+ metadata.gz: 521889ec673ef44681f582d65ca7a1a0069c9d8467d2613a0467632fe572abd6
4
+ data.tar.gz: 306a17db08fcf4769de7508f1e1fd30355e385c481a6e7dae7373ef085e13fb1
5
5
  SHA512:
6
- metadata.gz: 802d0b7be6130964c4d2d59cf4dfb1d2251f7b7f9c1cc307445e1cdc591a1c5ba7597cb1a83a8ed2f650980ae89e29623f8c880c70544d1e41b3c744a426ef74
7
- data.tar.gz: 680aad00ebdbcb6394b8efb0df1c2a74241b01695bc82587bcfb1d04dfa30f3ecbd78f61457add9b71422525b2797004c5515005c920b4ba75d44a63166a6e7c
6
+ metadata.gz: 0ac339db48acb0b6ec7b4e5b7cc6cc49589a5d2b1ab4e7a51e4e92d0f3cf657bf7143eebed1ea119fb2f84afc4adfb25c755a03e9ceaa42dcc8694cd0c92d1bd
7
+ data.tar.gz: 68a60c42844955fc1d2cf3ebfc131be2270c9ece8a8a59296c0fde4d60c9dfb2731482b38ad8d6af99e812d234748c1fea8f13faf9afbd46c9346781afc8f4b9
@@ -45,15 +45,6 @@ module RSpec
45
45
  module Trunk
46
46
  ANSI_ESCAPE_PATTERN = %r{(?:\e[@-Z\\-_]|\e\[[0-?]*[ -/]*[@-~])}
47
47
 
48
- CORE_METHODS = {
49
- name: [Module.instance_method(:name), String],
50
- class: [Kernel.instance_method(:class), Module]
51
- }.freeze
52
- CLASS_SUPERCLASS = Class.instance_method(:superclass)
53
- KERNEL_IS_A = Kernel.instance_method(:is_a?)
54
- MODULE_TO_S = Module.instance_method(:to_s)
55
- MEMORY_ADDRESS = /:0x\h+>/
56
-
57
48
  # Knapsack example detector instantiates all test cases in order to determine how to shard them
58
49
  # These instantiations should not generate test bundles, so we
59
50
  # disable the gem when running under knapsack_pro:rspec_test_example_detector
@@ -189,51 +180,21 @@ module RSpec
189
180
  end
190
181
 
191
182
  def description_arg(arg)
192
- if core_is_a?(arg, Module)
193
- module_description(arg, arg.to_s)
183
+ if arg.is_a?(Module)
184
+ arg.name || anonymous_module_name(arg)
194
185
  elsif default_to_s?(arg)
195
- klass = core_call(arg, :class)
196
- "#<#{module_description(klass, MODULE_TO_S.bind_call(klass))}>"
186
+ "#<#{arg.class.name || anonymous_module_name(arg.class)}>"
197
187
  else
198
188
  arg.to_s
199
189
  end
200
190
  end
201
191
 
202
192
  def anonymous_module_name(mod)
203
- return '#<Module>' unless core_is_a?(mod, Class)
204
-
205
- superclass = CLASS_SUPERCLASS.bind_call(mod)
206
- superclass = CLASS_SUPERCLASS.bind_call(superclass) while superclass && module_name(superclass).nil?
207
- superclass ? "#<Class < #{module_name(superclass)}>" : '#<Class>'
208
- end
209
-
210
- # `described` is the module's #to_s, which is RSpec's (and so 0.16.1's) name for it,
211
- # kept unless it has an address in it.
212
- def module_description(mod, described)
213
- return described unless MEMORY_ADDRESS.match?(described)
214
-
215
- name = module_name(mod)
216
- name.nil? || name.empty? ? anonymous_module_name(mod) : name
217
- end
193
+ return '#<Module>' unless mod.is_a?(Class)
218
194
 
219
- def module_name(mod)
220
- core_call(mod, :name)
221
- end
222
-
223
- # The arg's own method when it works as core's does, else core's: a class may define
224
- # .name for something else (private, or taking arguments).
225
- def core_call(obj, method_name)
226
- core, type = CORE_METHODS.fetch(method_name)
227
- value = obj.public_send(method_name)
228
- value.is_a?(type) ? value : core.bind_call(obj)
229
- rescue StandardError, NotImplementedError
230
- core.bind_call(obj)
231
- end
232
-
233
- def core_is_a?(obj, type)
234
- KERNEL_IS_A.bind_call(obj, type)
235
- rescue TypeError # a BasicObject
236
- false
195
+ superclass = mod.superclass
196
+ superclass = superclass.superclass while superclass && superclass.name.nil?
197
+ superclass ? "#<Class < #{superclass.name}>" : '#<Class>'
237
198
  end
238
199
 
239
200
  # Kernel's method, so an object whose own #method means something else
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec_trunk_flaky_tests
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.3
4
+ version: 0.17.0.pre.beta.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Trunk Technologies, Inc.