Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider a Module to be displayed similar to a Class, as a "primitive" #255

Closed
phorsuedzie opened this issue Jun 24, 2024 · 1 comment · Fixed by #263
Closed

Consider a Module to be displayed similar to a Class, as a "primitive" #255

phorsuedzie opened this issue Jun 24, 2024 · 1 comment · Fixed by #263

Comments

@phorsuedzie
Copy link
Contributor

phorsuedzie commented Jun 24, 2024

SuperDiff version: 0.12.1 (newest release available)

An inspected Module is not displayed with its name, but with its instance variables etc. (by ...::InstanceTreeBuilders::DefaultObject).

This is different from a Class, which is a SuperDiff.primitive?, and therefore displayed by ...::InstanceTreeBuilders::Primitive, with (only) its name.

The ugly output can be seen at an RSpec example description (rspec --format doc ...) that is auto-generated from a be_a matcher:

it { is_expected.to(be_a(TaskJob)) }

is shown as

is expected to be a kind of #<Module:0x00000001183d33f8 @_dependencies=[], @_included_block=#<Proc:0x000000011941db78>>

If (only) either SuperDiff.primitive? or Primitive.applies_to? is patched to (additionally) return true for a Module === value, then the output looks better:

is expected to be a kind of TaskJob
@jas14
Copy link
Collaborator

jas14 commented Sep 22, 2024

@phorsuedzie thanks for highlighting this, and for the small reproducible test case!

As you note, we fall back on the DefaultObject inspection tree builder, which shows the class (ironically Module) and the object address. It looks like the object inspection in rspec-support just calls #inspect on the module, which yields its name.

Confirming what you said, we already have a Primitive inspection tree builder, so we'd just need to add Module to the primitive list and add some unit and integration tests. I'm marking as a good first issue, PRs welcome!

jas14 pushed a commit that referenced this issue Sep 25, 2024
A module's inspection (used e.g. generate a description of an RSpec
example) has been improved to now include the module's name, which
identifies the module better than the previous string.

Old: `#<Module:0x0000000107f7a0a0>`
New (e.g.): `SuperDiff::Test`.

Closes #255.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants