Skip to content

Commit

Permalink
SSH task tests (#684)
Browse files Browse the repository at this point in the history
* Update description and ensure :deploy_to exists

* Add specs for ssh task
  • Loading branch information
lovro-bikic authored Aug 17, 2021
1 parent a7804f7 commit b5a9fa0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions spec/support/outputs/ssh.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ssh localhost -p 22 -tt 'cd .*/deploy && exec \$SHELL'
13 changes: 11 additions & 2 deletions spec/tasks/default_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,19 @@
end

describe 'ssh' do
it 'runs ssh' do
expect_any_instance_of(Kernel).to receive(:exec)
it 'runs ssh when :deploy_to exists' do
expect_any_instance_of(Kernel).to receive(:exec).with(output_file('ssh'))
subject.invoke
end

it "exits with an error if :deploy_to doesn't exist" do
deploy_to = Mina::Configuration.instance.remove(:deploy_to)

expect { subject.invoke }.to raise_error(SystemExit)
.and output(/deploy_to must be defined!/).to_stdout

Mina::Configuration.instance.set(:deploy_to, deploy_to)
end
end

describe 'debug_configuration_variables' do
Expand Down
3 changes: 2 additions & 1 deletion tasks/mina/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@
end
end

desc 'Open an ssh session to the server and cd to deploy_to folder'
desc 'Opens an SSH session and positions to :deploy_to folder'
task :ssh do
ensure!(:deploy_to)
exec %{#{Mina::Backend::Remote.new(nil).ssh} 'cd #{fetch(:deploy_to)} && exec $SHELL'}
end

0 comments on commit b5a9fa0

Please sign in to comment.