LoginSignup
5
0

More than 1 year has passed since last update.

#Rails logger でログ出力されることを #rspec で検証する ( expect logging in rspec )

Last updated at Posted at 2019-12-07

expect の中に Rails.logger みたいにメソッドまで書けたんだ...まるで知らずに今まで苦労していた気がする

書き方が推奨かどうかは不明

doubleを繋いだりした方が良いのかもしれない

with で特定のエラーメッセージを期待するが、ゆるい正規表現にしておく

    it 'logging as fatal' do
      expect(Rails.logger).to receive(:fatal).with(/Some error message/)
      subject
    end

logging - RSpec: how to test Rails logger message expectations? - Stack Overflow

Original by Github issue

チャットメンバー募集

何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

Twitter

5
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
0