def self.spec_helper_template
template = "require 'serverspec'\n<% if @os_type == 'UN*X' && @backend_type == 'Ssh' -%>\nrequire 'pathname'\n<% end -%>\n<% if @backend_type == 'Ssh' -%>\nrequire 'net/ssh'\n<% end -%>\n<% if @backend_type == 'WinRM' -%>\nrequire 'winrm'\n<% end -%>\n\ninclude SpecInfra::Helper::<%= @backend_type %>\n<% if @os_type == 'UN*X' -%>\ninclude SpecInfra::Helper::DetectOS\n<% else -%>\ninclude SpecInfra::Helper::Windows\n<% end -%>\n\n<% if @os_type == 'UN*X' -%>\nRSpec.configure do |c|\nif ENV['ASK_SUDO_PASSWORD']\nrequire 'highline/import'\nc.sudo_password = ask(\"Enter sudo password: \") { |q| q.echo = false }\nelse\nc.sudo_password = ENV['SUDO_PASSWORD']\nend\n<%- if @backend_type == 'Ssh' -%>\nc.before :all do\nblock = self.class.metadata[:example_group_block]\nif RUBY_VERSION.start_with?('1.8')\nfile = block.to_s.match(/.*@(.*):[0-9]+>/)[1]\nelse\nfile = block.source_location.first\nend\nhost = File.basename(Pathname.new(file).dirname)\nif c.host != host\nc.ssh.close if c.ssh\nc.host = host\noptions = Net::SSH::Config.for(c.host)\nuser = options[:user] || Etc.getlogin\n<%- if @vagrant -%>\nvagrant_up = `vagrant up \#{@hostname}`\nconfig = `vagrant ssh-config \#{@hostname}`\nif config != ''\nconfig.each_line do |line|\nif match = /HostName (.*)/.match(line)\nhost = match[1]\nelsif match = /User (.*)/.match(line)\nuser = match[1]\nelsif match = /IdentityFile (.*)/.match(line)\noptions[:keys] = [match[1].gsub(/\\\"/,'')]\nelsif match = /Port (.*)/.match(line)\noptions[:port] = match[1]\nend\nend\nend\n<%- end -%>\nc.ssh = Net::SSH.start(host, user, options)\nend\nend\n<%- end -%>\nend\n<% end -%>\n<% if @backend_type == 'WinRM'-%>\nRSpec.configure do |c|\nuser = <username>\npass = <password>\nendpoint = \"http://<hostname>:5985/wsman\"\n\nc.winrm = ::WinRM::WinRMWebService.new(endpoint, :ssl, :user => user, :pass => pass, :basic_auth_only => true)\nc.winrm.set_timeout 300 # 5 minutes max timeout for any operation\nend\n<% end -%>\n"
template
end