Skip to content

Instantly share code, notes, and snippets.

@hiroakis
Last active October 14, 2016 05:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save hiroakis/7302675 to your computer and use it in GitHub Desktop.
Save hiroakis/7302675 to your computer and use it in GitHub Desktop.
A patch for spec_helper.rb in serverspec. This patch enables "rake spec" command to require server login password.
--- spec_helper.rb.org 2013-11-04 19:21:50.000000000 +0900
+++ spec_helper.rb 2013-11-04 23:01:26.000000000 +0900
@@ -6,12 +6,9 @@
include Serverspec::Helper::DetectOS
RSpec.configure do |c|
- if ENV['ASK_SUDO_PASSWORD']
- require 'highline/import'
- c.sudo_password = ask("Enter sudo password: ") { |q| q.echo = false }
- else
- c.sudo_password = ENV['SUDO_PASSWORD']
- end
+ require 'highline/import'
+ password = ask("Enter ssh password: ") { |q| q.echo = false }
+ c.sudo_password = password
c.before :all do
block = self.class.metadata[:example_group_block]
if RUBY_VERSION.start_with?('1.8')
@@ -24,6 +21,7 @@
c.ssh.close if c.ssh
c.host = host
options = Net::SSH::Config.for(c.host)
+ options[:password] = password
user = options[:user] || Etc.getlogin
c.ssh = Net::SSH.start(c.host, user, options)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment