Move remaining core specs to use fewer shared examples#1369
Conversation
f311e61 to
f51cf1d
Compare
|
Let me split this up in two PRs then |
f51cf1d to
304b83a
Compare
304b83a to
83885f1
Compare
83885f1 to
a62129f
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 150 out of 150 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (5)
core/io/tty_spec.rb:1
- This spec can be flaky across CI/container environments because
/dev/ttymay be missing or inaccessible (e.g.,Errno::ENOENT,Errno::EACCES,Errno::ENODEV), not justErrno::ENXIO. Consider broadening the rescued errors (or guarding by checking existence/permissions) so the spec reliably skips when TTY access is not available.
core/file/to_path_spec.rb:1 - This
platform_is/guardblock definesbefore/afterhooks but contains no examples that use@dir. Either add the missing TMPFILE-related examples within this scope or remove the unused hooks to avoid dead setup code.
core/float/fdiv_spec.rb:1 - The second example’s description duplicates the first one verbatim, which makes failures harder to interpret. Rename the second description to reflect the distinct intent (e.g., division by a very large Integer).
core/kernel/dup_spec.rb:1 - The spec that verified
#dupcalls#initialize_copywas removed, which drops coverage for an important and observable part of Ruby’s object-copying semantics. Consider re-adding an explicit example assertinginitialize_copyis invoked (or adding equivalent coverage elsewhere in the same spec suite) so regressions induphooks are caught.
core/kernel/clone_spec.rb:1 - Similarly to
dup_spec, removing theinitialize_copyexpectation for#clonereduces coverage for clone’s copy hook behavior. Re-introduce an example that assertsinitialize_copyis called duringcloneto keep coverage of this user-visible contract.
eregon
left a comment
There was a problem hiding this comment.
Great stuff and some of the deduplication notably for Marshal will be very nice when improving those specs.
| it_behaves_like :method_to_s, :to_s | ||
| it_behaves_like :method_to_s_aliased, :to_s, -> meth { meth } | ||
| it "is an alias of Method#inspect" do | ||
| Method.instance_method(:to_s).should == Method.instance_method(:inspect) |
There was a problem hiding this comment.
For Float we have inspect is alias of to_s, I think that's good because to_s is more frequent than inspect, could you follow the pattern used for Float for other classes then?
This shared example didn't even care about the method. So I just mentioned in one of the methods that tests are found in a different file
a62129f to
aedfd18
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 151 out of 151 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (5)
core/method/to_s_spec.rb:1
Method#to_sis being tested using the:inspectmethod symbol. This makes the spec exercise the wrong API and will mask regressions inMethod#to_s. Update the shared example invocations to use:to_shere.
core/fiber/scheduler_spec.rb:1- This example has no assertions and will always pass, effectively removing coverage for
Fiber.schedulerwhile still reporting success. Either remove this spec file entirely (if intentionally redundant) or mark it as skipped (so it doesn't appear as a passing test), or add a minimal assertion thatFiber.schedulerreturns the currently configured scheduler.
core/kernel/dup_spec.rb:1 - The spec that verified
dupcalls#initialize_copywas removed, and there is no replacement in this file. Sinceinitialize_copyis part of the observable contract ofdup, this looks like a coverage regression; consider restoring the removed example or adding an equivalent assertion elsewhere.
core/kernel/clone_spec.rb:1 - Similar to
dup_spec, the spec that verifiedclonecalls#initialize_copywas removed without an apparent replacement. Consider restoring this coverage (or relocating it) to avoid losing behavioral guarantees aroundclone.
core/kernel/to_enum_spec.rb:1 - The expectation here is hard to read because the RHS uses
Array#eachwith a block (which returns the receiver array), while the LHS usesEnumerator#map(which allocates a new array). Consider rewriting the assertion to compare enumerated values more directly (e.g., comparingenum.to_ato[1, 2]) so the test intent is clearer.
aedfd18 to
4a91753
Compare
|
Ok, I should have applied all your suggestions (also in #1370). |
It's quite chonky but mostly more of the same for #1364. This converts the entirety of core specs.
Before:
3805 files, 35698 examples, 273269 expectations, 0 failure, 0 errors, 0 tagged
After:
3805 files, 34586 examples, 256944 expectations, 0 failure, 0 errors, 0 tagged
1112 fewer specs.