Suppress console output during RSpec tests

后端 未结 7 1113
小鲜肉
小鲜肉 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条回答
  • 2020-12-02 13:00

    An Rspec3.0 Version would be => in spec_helper.rb

    RSpec.configure do |c|
      c.before { allow($stdout).to receive(:puts) }
    end
    

    it will act as before(:each)

    but :each is default, so no need to write it explicitly

    0 讨论(0)
提交回复
热议问题