capistrano / capistrano/sshkit
Issue: SSHKit::Backend::Netssh binding change in run method breaks lookup in 'normal' block scope
- Dominant language
- Ruby
- Stars
- 1.2k
- Forks
- 257
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
in `SSHKit::Backend::Netssh#run` instance_exec is used to change the binding of the given block. With this binding change it is difficult to encapsulate an action in a service object for instance you have a cap-task:
``` ruby
desc 'Setup nginx configuration'
task :setup do
Nginx.new(self).setup
end
```
``` ruby
class Nginx < SimpleDelegator
...
def upload_files
on roles nginx_roles do |host|
set :host_server_name, host.properties.fetch(:host_server_name)
template 'assets.host.site', tmp_config_file
end
end
def tmp_config_file
'remote_file_name'
end
...
end
```
This does not work because the block is executed in the context of the `SSHKit::Backend::Netssh` object context and does not know the method tmp_config_file.
Why do I want to do such things? Testing! Rake and Cap tasks are difficult to test.
When I encapsulate the actions I can test the a little.
regards
dieter
Contributor guide
Assessment
This issue has not been assessed yet.