Skip to content

Commit

Permalink
Assert project file existence using patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
KaanOzkan committed Oct 18, 2024
1 parent 9b4a62c commit 80b852c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
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

0 comments on commit 80b852c

Please sign in to comment.