diff --git a/lib/tapioca/commands/abstract_gem.rb b/lib/tapioca/commands/abstract_gem.rb index c4752730d..4cf8c54d9 100644 --- a/lib/tapioca/commands/abstract_gem.rb +++ b/lib/tapioca/commands/abstract_gem.rb @@ -77,7 +77,7 @@ def initialize( def gems_to_generate(gem_names) return @bundle.dependencies if gem_names.empty? - gem_names.each_with_object([]) do |gem_name, gems| + (gem_names - @exclude).each_with_object([]) do |gem_name, gems| gem = @bundle.gem(gem_name) if gem.nil? diff --git a/lib/tapioca/gemfile.rb b/lib/tapioca/gemfile.rb index dc7b0bfb3..db67241e5 100644 --- a/lib/tapioca/gemfile.rb +++ b/lib/tapioca/gemfile.rb @@ -66,7 +66,7 @@ def load_dependencies sig { returns([T::Enumerable[Spec], T::Array[String]]) } def materialize_deps - deps = definition.locked_gems.dependencies.values + deps = definition.locked_gems.dependencies.except(*@excluded_gems).values materialized_dependencies = definition.resolve.materialize(deps) missing_spec_names = materialized_dependencies.missing_specs.map(&:name).to_set missing_specs = materialized_dependencies.missing_specs.map do |spec| diff --git a/spec/spec_with_project.rb b/spec/spec_with_project.rb index 182636037..53d722e7f 100644 --- a/spec/spec_with_project.rb +++ b/spec/spec_with_project.rb @@ -108,7 +108,7 @@ def assert_project_file_exist(path) # `Path` can include patterns such as `*`, useful for testing RBIs for real gems sig { params(path: String).void } def assert_project_file_match(path) - assert(Dir[path].any?) + assert(@project.glob(path).any?) end # Refute that `path` exists inside `@project` @@ -117,6 +117,13 @@ def refute_project_file_exist(path) refute(@project.file?(path)) end + # Refute that `path` exists inside `@project` + # `Path` can include patterns such as `*`, useful for testing RBIs for real gems + sig { params(path: String).void } + def refute_project_file_match(path) + refute(@project.glob(path).any?) + end + sig { params(strictness: String, file: String).void } def assert_file_strictness(strictness, file) assert_equal(strictness, Spoom::Sorbet::Sigils.file_strictness(@project.absolute_path_to(file))) diff --git a/spec/tapioca/cli/gem_spec.rb b/spec/tapioca/cli/gem_spec.rb index ce5276092..e4bf2cfbd 100644 --- a/spec/tapioca/cli/gem_spec.rb +++ b/spec/tapioca/cli/gem_spec.rb @@ -780,19 +780,23 @@ class Secret; end it "must respect exclude option" do @project.require_mock_gem(mock_gem("foo", "0.0.1")) - @project.require_mock_gem(mock_gem("bar", "0.3.0")) - @project.require_mock_gem(mock_gem("baz", "0.0.2")) + @project.require_mock_gem(mock_gem("bar", "0.3.0", dependencies: ["activemodel", "actionpack"])) + @project.require_mock_gem(mock_gem("baz", "0.0.2", dependencies: ["activemodel"])) @project.bundle_install! result = @project.tapioca("gem --all --exclude foo bar") refute_includes(result.out, "Compiled bar") + refute_includes(result.out, "Compiled actionpack") assert_stdout_includes(result, "Compiled baz") + assert_stdout_includes(result, "Compiled activemodel") refute_includes(result.out, "Compiled foo") refute_project_file_exist("sorbet/rbi/gems/foo@0.0.1.rbi") refute_project_file_exist("sorbet/rbi/gems/bar@0.3.0.rbi") + refute_project_file_match("sorbet/rbi/gems/actionpack@*.rbi") assert_project_file_exist("sorbet/rbi/gems/baz@0.0.2.rbi") + assert_project_file_match("sorbet/rbi/gems/activemodel@*.rbi") assert_empty_stderr(result) assert_success_status(result)