Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
cllns committed Nov 7, 2023
1 parent 3c555c3 commit 048eeb7
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/hanami/cli/commands/gem/new.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def run_install_command!(head:)
head_flag = head ? " --head" : ""
bundler.exec("hanami install#{head_flag}").tap do |result|
if result.successful?
bundler.exec("check").successful? || bundle.exec("install")
bundler.exec("check").successful? || bundler.exec("install")
else
raise HanamiInstallError.new(result.err)
end
Expand Down
26 changes: 26 additions & 0 deletions spec/unit/hanami/cli/commands/gem/new_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -594,4 +594,30 @@ class App < Hanami::App

expect { subject.call(app: app) }.to raise_error(Hanami::CLI::PathAlreadyExistsError)
end

it "calls bundle install if bundle check fails" do
expect(bundler).to receive(:install!)
.at_least(1)
.and_return(true)

expect(bundler).to receive(:exec)
.with("hanami install")
.at_least(1)
.and_return(successful_system_call_result)

expect(bundler).to receive(:exec)
.with("check")
.at_least(1)
.and_return(
instance_double(Hanami::CLI::SystemCall::Result, successful?: false)
)

expect(bundler).to receive(:exec)
.with("install")
.once
.and_return(successful_system_call_result)

app_name = "no_gems_installed"
subject.call(app: app_name)
end
end

0 comments on commit 048eeb7

Please sign in to comment.