Fewer shared examples for ARGF/Array/Complex/Data/Dir/Encoding#1368
Conversation
Also add a test for `ARGF.inspect`, which is an alias for `ARGF.to_s`.
95da0fe to
af1dbef
Compare
There was a problem hiding this comment.
Pull request overview
Continues the project of replacing one-method shared examples with direct alias equality checks (per issue #1364). Behavior specs are moved into the canonical method's spec file, and alias spec files now assert Method#==/UnboundMethod#== against the canonical method. Net effect: 170 fewer examples, but more expectations and equivalent coverage.
Changes:
- Inlined shared example bodies into canonical spec files for ARGF, Array, Complex, Data, Dir, and Encoding.
- Replaced shared-example invocations in alias spec files with
Method#==/UnboundMethod#==assertions; added a newARGF#inspectalias spec. - Deleted the corresponding now-unused
shared/files.
Reviewed changes
Copilot reviewed 90 out of 90 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| core/argf/{readlines,pos,fileno,filename,eof,each_line,each_byte,each_char,each_codepoint}_spec.rb | Inlined canonical behavior from shared specs. |
| core/argf/{to_a,to_i,tell,path,each,inspect}_spec.rb | Replaced shared spec with alias equality check (inspect_spec.rb is new). |
| core/argf/shared/{readlines,pos,fileno,filename,eof,each_line,each_byte,each_char,each_codepoint}.rb | Removed. |
| core/array/{collect,find_index,inspect,join,length,push,replace,select,unshift,element_reference}_spec.rb | Inlined canonical behavior. |
| core/array/{append,filter,index,map,prepend,size,slice,to_s}_spec.rb | Replaced shared specs with alias checks. |
| core/array/shared/{collect,index,inspect,join (partial),length,push,replace,select,slice,unshift}.rb | Removed (join still keeps array_join_with_string_separator). |
| core/complex/{abs,arg,conjugate,divide,imaginary,rectangular}_spec.rb | Inlined canonical behavior. |
| core/complex/{angle,conj,imag,magnitude,phase,quo,rect}_spec.rb | Replaced shared specs with alias checks. |
| core/complex/shared/{abs,arg,conjugate,divide,image,rect}.rb | Removed. |
| core/data/inspect_spec.rb, core/data/to_s_spec.rb, core/data/shared/inspect.rb | Behavior moved to inspect_spec.rb; to_s_spec.rb now alias-checks; shared file removed. |
| core/dir/{tell,path,pwd,open,exist}_spec.rb | Inlined canonical behavior. |
| core/dir/{to_path,pos,getwd}_spec.rb | Replaced shared specs with alias checks. |
| core/dir/shared/{exist,open,path,pwd}.rb, core/dir/shared/pos.rb | Removed (pos keeps dir_pos_set). |
| core/encoding/name_spec.rb, core/encoding/to_s_spec.rb, core/encoding/shared/name.rb | Behavior inlined into name_spec.rb; to_s_spec.rb alias-checks; shared file removed. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
af1dbef to
9bd9081
Compare
eregon
left a comment
There was a problem hiding this comment.
Great!
Do you do these manually with some search/replace or you have some script or something?
Nah, it's pretty manual. Seach and replace works ok, just do it twice (once for no arguments, and once with to take I wanted to use RDoc to tell me what are aliases but it actually doesn't show for class methods, that's a bit annoying. But I check all the shared examples anyways because there are some that are only used once for historic reasons (like being aliased in the past but it got removed). Surely it can be done in a better way but I'll be done with this soon anways. |
Working my way through these. #1364
Before:
3804 files, 35682 examples, 278464 expectations, 0 failure, 0 errors, 0 taggedAfter:
3805 files, 35512 examples, 292300 expectations, 0 failure, 0 errors, 0 tagged170 fewer specs.