Skip to content

Commit

Permalink
Add test for RBI version filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
egiurleo committed Feb 22, 2024
1 parent 4b26fb7 commit 3fa209d
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions spec/tapioca/cli/annotations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,42 @@ class AnnotationForSpoom; end

repo.destroy!
end

it "filters RBI file based on gem version" do
foo = mock_gem("foo", "0.3.4") do
write!("lib/foo.rb", <<~BAR)
class Foo; end
BAR
end

@project.require_mock_gem(foo)
@project.bundle_install!

repo = create_repo({
foo: <<~RBI,
# typed: false
# @version > 0.3.5
class AnnotationForFoo; end
class Foo; end
RBI
})

result = @project.tapioca("annotations --sources #{repo.absolute_path}")

assert_stdout_includes(result, "create sorbet/rbi/annotations/foo.rbi")

assert_project_annotation_equal("sorbet/rbi/annotations/foo.rbi", <<~RBI)
# typed: false
# DO NOT EDIT MANUALLY
# This file was pulled from a central RBI files repository.
# Please run `bin/tapioca annotations` to update it.
class Foo; end
RBI

assert_success_status(result)

repo.destroy!
end
end

private
Expand Down

0 comments on commit 3fa209d

Please sign in to comment.