Skip to content

Commit 1661a46

Browse files
committed
Add test that does not use Gemfile.lock
1 parent d2298fb commit 1661a46

File tree

1 file changed

+46
-1
lines changed

1 file changed

+46
-1
lines changed

spec/tapioca/cli/annotations_spec.rb

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class AnnotationsTest < SpecWithProject
2222

2323
assert_stdout_equals(<<~OUT, result)
2424
Retrieving index from central repository... Done
25-
Listing gems from bundle... Done
25+
Listing gems from Gemfile.lock... Done
2626
Removing annotations for gems that have been removed... Nothing to do
2727
Fetching gem annotations from central repository... Nothing to do
2828
OUT
@@ -398,6 +398,51 @@ class Foo; end
398398

399399
repo.destroy!
400400
end
401+
402+
it "gets annotations if application uses a gems.rb" do
403+
gemfile_content = @project.read("Gemfile")
404+
gemfile_lock = @project.read("Gemfile.lock")
405+
406+
@project.remove!("Gemfile")
407+
@project.remove!("Gemfile.lock")
408+
409+
@project.write!("gems.rb", <<~RBI)
410+
source("https://rubygems.org")
411+
412+
gemspec name: "tapioca", path: "#{MockProject::TAPIOCA_PATH}"
413+
RBI
414+
@project.bundle_install!
415+
416+
repo = create_repo({
417+
rbi: <<~RBI,
418+
# typed: true
419+
420+
class AnnotationForRBI; end
421+
RBI
422+
})
423+
424+
result = @project.tapioca("annotations --sources #{repo.absolute_path}")
425+
assert_stdout_includes(result, "create sorbet/rbi/annotations/rbi.rbi")
426+
assert_project_annotation_equal("sorbet/rbi/annotations/rbi.rbi", <<~RBI)
427+
# typed: true
428+
429+
# DO NOT EDIT MANUALLY
430+
# This file was pulled from a central RBI files repository.
431+
# Please run `bin/tapioca annotations` to update it.
432+
433+
class AnnotationForRBI; end
434+
RBI
435+
436+
assert_success_status(result)
437+
438+
@project.remove!("gems.rb")
439+
@project.remove!("gems.lock")
440+
@project.write!("Gemfile", gemfile_content)
441+
@project.write!("Gemfile.lock", gemfile_lock)
442+
@project.bundle_install!
443+
444+
repo.destroy!
445+
end
401446
end
402447

403448
private

0 commit comments

Comments
 (0)