Refactor contents of steps into helper methods that Cucumber-Nagios (Cuken?) users can also use in their own steps by adding Cuken::Helper into Cucumber's World or Rspec's config.
To disambiguate what methods come from here, these methods should have some refix such as: cn_... or cuken_... (preferred, since it is short but more descritive than cn_...)
Example:
This:
When /^I ssh to "([^\"]*)" with the following credentials:$/ do |hostname, table|
@keys = []
@auth_methods ||= %w(password)
session = table.hashes.first
session_keys = Array.new(@keys)
session_auth_methods = Array.new(@auth_methods)
if session["keyfile"]
session_keys << session["keyfile"]
session_auth_methods << "publickey"
end
When /^I ssh to "([^\"]*)" with the following credentials:$/ do |hostname, table|
session = cuken_ssh_session(table)
lambda {
@connection = Net::SSH.start(hostname,
session["username"],
:password => session["password"],
:auth_methods => session["auth_methods"],
:keys => session["keys"])
}.should_not raise_error
end
Refactor contents of steps into helper methods that Cucumber-Nagios (Cuken?) users can also use in their own steps by adding Cuken::Helper into Cucumber's World or Rspec's config. To disambiguate what methods come from here, these methods should have some refix such as:
cn_...
orcuken_...
(preferred, since it is short but more descritive thancn_...
)Example: This: When /^I ssh to "([^\"]*)" with the following credentials:$/ do |hostname, table| @keys = [] @auth_methods ||= %w(password) session = table.hashes.first session_keys = Array.new(@keys) session_auth_methods = Array.new(@auth_methods) if session["keyfile"] session_keys << session["keyfile"] session_auth_methods << "publickey" end
Would become this: