Skip to content

Commit

Permalink
Add integration tests for caching scenario
Browse files Browse the repository at this point in the history
  • Loading branch information
Nu-hin committed Dec 22, 2024
1 parent 4288016 commit ff79d78
Showing 1 changed file with 39 additions and 1 deletion.
40 changes: 39 additions & 1 deletion spec/integration/ssh_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,53 @@

describe 'Connecting to remote host with SSH adapter',
type: :integration do
let(:save_cache) { false }

let(:ec) do
RemoteRuby::ExecutionContext.new(
adapter: RemoteRuby::SSHAdapter,
host: ssh_host,
user: ssh_user,
working_dir: ssh_workdir
working_dir: ssh_workdir,
use_cache: false,
save_cache: save_cache
)
end

context 'in caching mode' do
let(:cache_prefix) { '[C] ' }
let(:save_cache) { true }
let(:cec) do
RemoteRuby::ExecutionContext.new(
adapter: RemoteRuby::SSHAdapter,
host: ssh_host,
user: ssh_user,
working_dir: ssh_workdir,
use_cache: true,
save_cache: false,
cache_prefix: cache_prefix
)
end

it 'replays stdout and stderr' do
expect do
ec.execute do
puts 'Hello, World!'
warn 'Something went wrong!'
end
end.to output("Hello, World!\n").to_stdout.and output("Something went wrong!\n").to_stderr

expect do
cec.execute do
puts 'Hello, World!'
warn 'Something went wrong!'
end
end.to output("#{cache_prefix}Hello, World!\n")
.to_stdout
.and output("#{cache_prefix}Something went wrong!\n").to_stderr
end
end

context 'with do-blocks' do
it 'reads string from stdin' do
with_stdin_redirect("John doe\n") do
Expand Down

0 comments on commit ff79d78

Please sign in to comment.