Shopify / constant_resolver

Resolve a partially qualified Ruby constant reference to the fully qualified name and the path of the file defining it.
MIT License
26 stars 10 forks source link

add test for resolution of ambiguous constants #23

Closed exterm closed 3 years ago

exterm commented 3 years ago

https://github.com/Shopify/packwerk/issues/136 brought up a possible issue with a constant that is used as a namespace but also defined in its own file:

# sales.rb
module Sales
end
# sales/entry.rb
module Sales
  class Entry
  end
end

In this case the Sales constant is technically defined in both places, but we want to infer the more specific sales.rb as its location.

This test proves constant_resolver is doing the right thing in this case.