Skip to content

Commit

Permalink
Add a test covering a transitive dependency that is shared with an ex…
Browse files Browse the repository at this point in the history
…cluded gem
  • Loading branch information
rzane committed Nov 27, 2024
1 parent a9cbf34 commit 47032ce
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
9 changes: 8 additions & 1 deletion spec/spec_with_project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand All @@ -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)))
Expand Down
8 changes: 5 additions & 3 deletions spec/tapioca/cli/gem_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -780,21 +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", dependencies: ["actionpack"]))
@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/[email protected]")
refute_project_file_exist("sorbet/rbi/gems/[email protected]")
refute_project_file_exist("sorbet/rbi/gems/actionpack@7.0.6.rbi")
refute_project_file_match("sorbet/rbi/gems/actionpack@*.rbi")
assert_project_file_exist("sorbet/rbi/gems/[email protected]")
assert_project_file_match("sorbet/rbi/gems/activemodel@*.rbi")

assert_empty_stderr(result)
assert_success_status(result)
Expand Down

0 comments on commit 47032ce

Please sign in to comment.