Ruby on rails ServerSpec无法对远程windows ami执行测试
我有一台包含serverspec测试的测试机器。这是一台ubuntu机器,我想在windows机器上使用WinRM运行测试 当执行测试时,它会立即失败,看起来它试图在本地运行测试,而不是针对远程主机 我现在已经在spec_helper.rb中硬编码了主机名,但为了完整性,我将发布Rakefile 耙子:Ruby on rails ServerSpec无法对远程windows ami执行测试,ruby-on-rails,ruby,rspec,winrm,serverspec,Ruby On Rails,Ruby,Rspec,Winrm,Serverspec,我有一台包含serverspec测试的测试机器。这是一台ubuntu机器,我想在windows机器上使用WinRM运行测试 当执行测试时,它会立即失败,看起来它试图在本地运行测试,而不是针对远程主机 我现在已经在spec_helper.rb中硬编码了主机名,但为了完整性,我将发布Rakefile 耙子: require 'rake' require 'rspec/core/rake_task' hosts = %w( 我的主机名 ) Spec_helper.rb require 'serve
require 'rake'
require 'rspec/core/rake_task'
hosts = %w(
我的主机名
)
Spec_helper.rb
require 'serverspec'
require 'winrm'
set :backend, :winrm
user = "Packer"
pass = "Drj33l1n9"
endpoint = "http://hostname:5985/wsman"
opts = {
user: user,
password: pass,
endpoint: endpoint,
operation_timeout: 30,
}
winrm = WinRM::Connection.new ( opts)
Specinfra.configuration.winrm = winrm
样本规格rb
require 'spec_helper'
set :os, :family => 'windows'
describe file('c:/windows') do
it { should be_directory }
end
describe file('c:/temp/testfile.txt') do
it { should be_file }
end
describe service('Schedule') do
it { should be_installed }
it { should be_enabled }
it { should be_running }
it { should have_start_mode("Automatic") }
end
describe port(139) do
it { should be_listening }
end
describe user('Administrator') do
it { should exist }
it { should belong_to_group('Administrators')}
end
这是故障的输出
/usr/bin/ruby2.3 -I/var/lib/gems/2.3.0/gems/rspec-support-3.5.0/lib:/var/lib/gems/2.3.0/gems/rspec-core-3.5.4/lib /var/lib/gems/2.3.0/gems/rspec-core-3.5.4/exe/rspec --pattern spec/base/\*_spec.rb
File "c:/windows"
should be directory (FAILED - 1)
File "c:/temp/testfile.txt"
should be file (FAILED - 2)
sample\u spec
在spec/base
中?@MattSchuchard是的。你在执行什么rake任务,为什么要设置未使用的变量角色
,为什么要将操作系统
硬编码为Windows,如果在Ubuntu上执行测试,我预计会有更多的测试失败。
/usr/bin/ruby2.3 -I/var/lib/gems/2.3.0/gems/rspec-support-3.5.0/lib:/var/lib/gems/2.3.0/gems/rspec-core-3.5.4/lib /var/lib/gems/2.3.0/gems/rspec-core-3.5.4/exe/rspec --pattern spec/base/\*_spec.rb
File "c:/windows"
should be directory (FAILED - 1)
File "c:/temp/testfile.txt"
should be file (FAILED - 2)