diff --git a/spec/support/outputs/ssh.txt b/spec/support/outputs/ssh.txt index 971b7765..849ad9c3 100644 --- a/spec/support/outputs/ssh.txt +++ b/spec/support/outputs/ssh.txt @@ -1 +1 @@ -ssh localhost -p 22 -tt 'cd .*/deploy && exec \$SHELL' \ No newline at end of file +cd .*/deploy && exec \$SHELL \ No newline at end of file diff --git a/spec/tasks/default_spec.rb b/spec/tasks/default_spec.rb index 60c49a16..9b62e037 100644 --- a/spec/tasks/default_spec.rb +++ b/spec/tasks/default_spec.rb @@ -71,21 +71,20 @@ end describe 'ssh' do - it 'runs ssh when :deploy_to exists' do - allow(Kernel).to receive(:exec) - - task.invoke - - expect(Kernel).to have_received(:exec).with(output_file('ssh')) + it 'opens an SSH connection when :deploy_to exists' do + expect do + invoke_all + end.to change { Mina::Configuration.instance.fetch(:execution_mode) }.to(:exec) + .and output(output_file('ssh')).to_stdout end - it "exits with an error if :deploy_to doesn't exist" do - deploy_to = Mina::Configuration.instance.remove(:deploy_to) + it "exits with an error message when :deploy_to isn't set" do + Mina::Configuration.instance.remove(:deploy_to) - expect { task.invoke }.to raise_error(SystemExit) - .and output(/deploy_to must be defined!/).to_stdout - - Mina::Configuration.instance.set(:deploy_to, deploy_to) + expect do + invoke_all + end.to raise_error(SystemExit) + .and output(/deploy_to must be defined!/).to_stdout end end diff --git a/tasks/mina/default.rb b/tasks/mina/default.rb index bfc0771b..bc421233 100644 --- a/tasks/mina/default.rb +++ b/tasks/mina/default.rb @@ -86,8 +86,11 @@ end end -desc 'Opens an SSH session and positions to :deploy_to folder' +desc 'Open an SSH connection and position to :deploy_to folder' task :ssh do ensure!(:deploy_to) - Kernel.exec %(#{Mina::Backend::Remote.new(nil).ssh} 'cd #{fetch(:deploy_to)} && exec $SHELL') + + set :execution_mode, :exec + + command "cd #{fetch(:deploy_to)} && exec $SHELL" end