运行测试时如何使以下RightAWS消息静音

Lau*_*ung 3 ruby testing rspec amazon-web-services rightscale

我正在使用RighAWS gem,并在http级别进行模拟,以便在我的测试中执行RightAWS代码.

当发生这种情况时,我得到以下输出

....New RightAws::S3Interface using per_request-connection mode Opening new HTTP connection to s3.amazonaws.com:80 .New RightAws::S3Interface using per_request-connection mode .

即使所有测试都通过,但当我确实遇到错误时,由于此输出而难以扫描它们.沉默它有一个很好的方法吗?

bhu*_*ups 6

您可以使用null设备进行日志记录:

s3 = RightAws::S3Interface.new(access_key, secret_key, {:port => 80, :protocol => 'http', :logger => Logger.new('/dev/null')})  //on unix system
s3 = RightAws::S3Interface.new(access_key, secret_key, {:port => 80, :protocol => 'http', :logger => Logger.new('NUL')})  //on windows
Run Code Online (Sandbox Code Playgroud)