auxesis / cucumber-nagios

Systems testing plugin for Nagios with Cucumber + Webrat + Mechanize + Net::SSH
http://cucumber-nagios.org/
MIT License
257 stars 43 forks source link

Feature: Cuken::Helper module #53

Closed hedgehog closed 13 years ago

hedgehog commented 13 years ago

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

  lambda {
    @connection = Net::SSH.start(hostname, session["username"], :password => session["password"], 
                                                                :auth_methods => session_auth_methods,
                                                                :keys => session_keys)
  }.should_not raise_error
end

Would become this:

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
hedgehog commented 13 years ago

Auxesis asked me to take over CN, so closing this issue, since it is resolved in: https://github.com/hedgehog/cucumber-nagios