Suppress console output during RSpec tests

后端 未结 7 1133
小鲜肉
小鲜肉 2020-12-02 12:24

I am testing the class which put on the console some messages (with puts, p warnings and etc.). I am just wondering if there is any ability to suppress this output during R

7条回答
  •  -上瘾入骨i
    2020-12-02 12:43

    After trying all of these examples, I ended up using this varation which does not silence or mute binding.pry

    # frozen_string_literal: true
    
    RSpec.configure do |config|
      config.before(:each) do
        allow($stdout).to receive(:puts)
        allow($stdout).to receive(:write)
      end
    end
    

提交回复
热议问题