gpt4 book ai didi

ruby - rake/Rspec : How to suppress/quiet/silent the first output line showing the command with --pattern ?

转载 作者:数据小太阳 更新时间:2023-10-29 07:14:17 25 4
gpt4 key购买 nike

问题:

如果我运行 ServerSpec (基于 RSpec )到 Rake使用以下命令之一:

  • rake
  • rake spec
  • rake spec:all
  • rake spec:<host>
  • bundle exec rake
  • ...

Rake 将它执行的命令打印到 stdout在 serverspec 输出之前:

/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

...该行出现。

问题:

如何防止 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

最佳答案

尝试改变

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

关于ruby - rake/Rspec : How to suppress/quiet/silent the first output line showing the command with --pattern ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26297823/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com