diff --git a/lib/packwerk/package.rb b/lib/packwerk/package.rb index 95988aa57..47d253938 100644 --- a/lib/packwerk/package.rb +++ b/lib/packwerk/package.rb @@ -42,7 +42,7 @@ def dependency?(package) def package_path?(path) return true if root? - path.start_with?(@name) + path.start_with?(@name + "/") end sig { params(other: T.untyped).returns(T.nilable(Integer)) } diff --git a/test/unit/packwerk/package_test.rb b/test/unit/packwerk/package_test.rb index 083916b6d..8c68edef8 100644 --- a/test/unit/packwerk/package_test.rb +++ b/test/unit/packwerk/package_test.rb @@ -22,6 +22,10 @@ class PackageTest < Minitest::Test assert_equal(true, root_package.package_path?("components/unknown")) end + test "#package_path? returns false for different path with matching prefix" do + assert_equal(false, @package.package_path?("components/timeline_ui/something.rb")) + end + test "#<=> compares against name" do assert_equal(-1, @package <=> Package.new(name: "components/xyz", config: {})) assert_equal(0, @package <=> Package.new(name: "components/timeline", config: {}))