5

问题:

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

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

stdoutRake在 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.

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
4

1 回答 1

7

尝试从

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
于 2014-10-10T12:48:34.177 回答