Skip to content

Add test coverage for interface! rejecting classes#33

Open
mliem2k wants to merge 1 commit into
Shopify:mainfrom
mliem2k:test/interface-not-a-class
Open

Add test coverage for interface! rejecting classes#33
mliem2k wants to merge 1 commit into
Shopify:mainfrom
mliem2k:test/interface-not-a-class

Conversation

@mliem2k

@mliem2k mliem2k commented Jul 12, 2026

Copy link
Copy Markdown

Summary

interface! already raises TypeError when called on a Class:

class MyClass
  interface! # already raises TypeError
end

This also already covers the class << self case from the issue, since a module's singleton class is itself an instance of Class:

module MyInterface
  class << self
    interface! # already raises TypeError, since MyInterface.singleton_class is a Class
  end
end

This existing guard (in TypeToolkit.make_interface!) wasn't covered by any spec, so it was easy to lose track of. This PR adds specs for both raising cases, plus a sanity check that interface! still works normally on a plain module.

Fixes #4

Test plan

  • bundle exec rake test — 92 runs, 0 failures
  • bundle exec rake rubocop — no offenses
  • bundle exec rake typecheck — no errors

interface! already guards against being called on a Class (raising
TypeError), which also covers the class << self case since a module's
singleton class is itself a Class. Add specs to lock in this behavior.
Copilot AI review requested due to automatic review settings July 12, 2026 12:29

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enforce that interface! isn't called from a class

2 participants