Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assert project file existence using patterns #2049

Merged
merged 1 commit into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions spec/spec_with_project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,13 @@ def assert_project_file_exist(path)
assert(@project.file?(path))
end

# Assert that `path` exists inside project.
# `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?)
end

# Refute that `path` exists inside `@project`
sig { params(path: String).void }
def refute_project_file_exist(path)
Expand Down
2 changes: 1 addition & 1 deletion spec/tapioca/cli/gem_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,7 @@ class Secret; end
assert_project_file_exist("sorbet/rbi/gems/[email protected]")
assert_project_file_exist("sorbet/rbi/gems/[email protected]")
assert_project_file_exist("sorbet/rbi/gems/[email protected]")
assert_project_file_exist("sorbet/rbi/gems/rack@2.2.10.rbi")
assert_project_file_match("sorbet/rbi/gems/rack@*.rbi")
refute_project_file_exist("sorbet/rbi/gems/[email protected]")

assert_empty_stderr(result)
Expand Down
Loading