如果我使用以下命令之一通过ServerSpec
运行RSpec
(基于Rake
):
rake
rake spec
rake spec:all
rake spec:<host>
bundle exec rake
Rake在serverspec输出之前将它执行的命令打印到stdout
:
/usr/bin/ruby1.9.1
-I/var/lib/gems/1.9.1/gems/rspec-core-3.1.6/lib:/var/lib/gems/1.9.1/gems/rspec-support-3.1.2/lib
/var/lib/gems/1.9.1/gems/rspec-core-3.1.6/exe/rspec
--pattern spec/<host>/\*_spec.rb
如果我将目标主机手动传递给rspec
,就像这样......
TARGET_HOST=<host> rspec
...该行 NOT 显示。
如何阻止Rake
输出此行/命令?
我使用serverspec-init
生成的默认Rakefile。
require 'rake'
require 'rspec/core/rake_task'
task :spec => 'spec:all'
task :default => :spec
namespace :spec do
targets = []
Dir.glob('./spec/*').each do |dir|
next unless File.directory?(dir)
targets << File.basename(dir)
end
task :all => targets
task :default => :all
targets.each do |target|
desc "Run serverspec tests to #{target}"
RSpec::Core::RakeTask.new(target.to_sym) do |t|
ENV['TARGET_HOST'] = target
t.pattern = "spec/#{target}/*_spec.rb"
end
end
end
答案 0 :(得分:6)
尝试从
更改RSpec::Core::RakeTask.new(target.to_sym) do |t|
ENV['TARGET_HOST'] = target
t.pattern = "spec/#{target}/*_spec.rb"
end
到
RSpec::Core::RakeTask.new(target.to_sym) do |t|
ENV['TARGET_HOST'] = target
t.pattern = "spec/#{target}/*_spec.rb"
t.verbose = false
end