0.0
A long-lived project that still receives updates
A SSH wrapper for nice readability. Is compatible with spectre-core.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies
 Project Readme

Spectre SSH

Build Gem Version

This is a spectre module which provides SSH access functionality to the spectre framework.

Install

$ sudo gem install spectre-ssh

Configure

Add the module to your spectre.yml

include:
 - spectre/ssh

Configure some predefined SSH connection options in your environment file

ssh:
  some_ssh_conn:
    host: some.server.com
    username: dummy
    password: '*****'
    key: path/to/.ssh/id_rsa
    passphrase: '*****'
    proxy_host: some_proxy_host
    proxy_port: 1234

Usage

With the SSH helper you can define SSH connection parameters in the environment file and use the ssh function in your specs.

Within the ssh block there are the following functions available

Method Parameters Description
file_exists file_path Checks if a file exists and returns a boolean value
owner_of file_path Returns the owner of a given file
can_connect? none Returns true if a connection could be established
exec command Executes a command via SSH
output none The output of the SSH command, which was last executed
ssh 'some_ssh_conn' do # use connection name from config
  file_exists('../path/to/some/existing_file.txt').should_be true
  owner_of('/bin').should_be 'root'
  exec 'ls -al'
end
ssh 'some_server.com', username: 'dummy', password: '*****', proxy_host: 'some_proxy_host', proxy_port: 1234  do 
  file_exists('../path/to/some/existing_file.txt').should_be true
  owner_of('/bin').should_be 'root'
  exec 'ls -al'
end

You can also use the ssh function without configuring any connection in your environment file, by providing parameters to the function. This is helpful, when generating the connection parameters during the spec run.

ssh 'some.server.com', username: 'dummy', password: '*****'  do
  file_exists('../path/to/some/existing_file.txt').should_be true
  owner_of('/bin').should_be 'root'
end
ssh 'some.server.com', username: 'dummy', key: 'path/to/.ssh/id_rsa', passphrase: '*****'  do
  file_exists('../path/to/some/existing_file.txt').should_be true
  owner_of('/bin').should_be 'root'
end