-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3b24432
commit cb7a760
Showing
5 changed files
with
39 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ module Foo | |
|
||
describe "without git" do | ||
before do | ||
@project.bundle_install! | ||
@project.tapioca("configure") | ||
end | ||
|
||
|
@@ -35,19 +36,19 @@ module Foo | |
# TODO: understand why this fails with `before(:all)` | ||
# before(:all) do | ||
before do | ||
# @project.require_default_gems | ||
@project.bundle_install! | ||
@project.tapioca("configure") | ||
check_exec @project.exec("git init") | ||
check_exec @project.exec("git config user.email '[email protected]'") | ||
check_exec @project.exec("git config user.name 'Test User'") | ||
@project.bundle_install! | ||
check_exec @project.exec("git config commit.gpgsign false") | ||
FileUtils.mkdir_p("#{@project.absolute_path}/sorbet/rbi/gems") | ||
check_exec @project.exec("git add .") | ||
check_exec @project.exec("git commit -m 'Initial commit'") | ||
$stdout.puts %x(cd #{@project.absolute_path} && git status) | ||
end | ||
|
||
after do | ||
ENV["BUNDLE_GEMFILE"] = nil | ||
@project.write_gemfile!(project.tapioca_gemfile) | ||
@project.require_default_gems | ||
@project.remove!("sorbet/rbi") | ||
|
@@ -57,8 +58,8 @@ module Foo | |
@project.remove!("config/application.rb") | ||
@project.remove!(".bundle") | ||
@project.remove!("Gemfile.lock") | ||
ensure | ||
@project.remove!("output") | ||
ensure | ||
@project.remove!("output") | ||
end | ||
|
||
it "creates the RBI for a newly added gem" do | ||
|
@@ -87,9 +88,7 @@ module Foo | |
assert_project_file_exist("sorbet/rbi/gems/[email protected]") | ||
|
||
# Modify the gem | ||
foo = mock_gem("foo", "0.0.2") do | ||
write!("lib/foo.rb", FOO_RB) | ||
end | ||
update_gem foo, "0.0.2" | ||
@project.require_mock_gem(foo) | ||
@project.bundle_install! | ||
|
||
|
@@ -122,37 +121,38 @@ module Foo | |
refute_project_file_exist("sorbet/rbi/gems/[email protected]") | ||
end | ||
|
||
it "deletes untracked RBI files" do | ||
# Create an untracked RBI file | ||
FileUtils.touch("#{@project.absolute_path}/sorbet/rbi/gems/[email protected]") | ||
it "deletes untracked RBI files" do | ||
|
||
assert_project_file_exist("/sorbet/rbi/gems/[email protected]") | ||
# Create an untracked RBI file | ||
FileUtils.touch("#{@project.absolute_path}/sorbet/rbi/gems/[email protected]") | ||
|
||
check = ::RubyLsp::Tapioca::RunGemRbiCheck.new | ||
check.run(@project.absolute_path) | ||
assert_project_file_exist("/sorbet/rbi/gems/[email protected]") | ||
|
||
refute_project_file_exist("sorbet/rbi/gems/[email protected]") | ||
end | ||
check = ::RubyLsp::Tapioca::RunGemRbiCheck.new | ||
check.run(@project.absolute_path) | ||
|
||
it "restores deleted RBI files" do | ||
# Create and delete a tracked RBI file | ||
FileUtils.touch("#{@project.absolute_path}/sorbet/rbi/gems/[email protected]") | ||
@project.exec("git add sorbet/rbi/gems/[email protected]") | ||
@project.exec("git commit -m 'Add foo RBI'") | ||
FileUtils.rm("#{@project.absolute_path}/sorbet/rbi/gems/[email protected]") | ||
refute_project_file_exist("sorbet/rbi/gems/[email protected]") | ||
end | ||
|
||
refute_project_file_exist("sorbet/rbi/gems/[email protected]") | ||
it "restores deleted RBI files" do | ||
# Create and delete a tracked RBI file | ||
FileUtils.touch("#{@project.absolute_path}/sorbet/rbi/gems/[email protected]") | ||
@project.exec("git add sorbet/rbi/gems/[email protected]") | ||
@project.exec("git commit -m 'Add foo RBI'") | ||
FileUtils.rm("#{@project.absolute_path}/sorbet/rbi/gems/[email protected]") | ||
|
||
check = ::RubyLsp::Tapioca::RunGemRbiCheck.new | ||
check.run(@project.absolute_path) | ||
refute_project_file_exist("sorbet/rbi/gems/[email protected]") | ||
|
||
assert_project_file_exist("sorbet/rbi/gems/[email protected]") | ||
end | ||
check = ::RubyLsp::Tapioca::RunGemRbiCheck.new | ||
check.run(@project.absolute_path) | ||
|
||
assert_project_file_exist("sorbet/rbi/gems/[email protected]") | ||
end | ||
end | ||
|
||
def check_exec(command) | ||
result = command | ||
raise "fail" unless result.status | ||
raise "failing" unless result.status | ||
end | ||
end | ||
end | ||
|