How to get Rails.logger printing to the console/stdout when running rspec?

前端 未结 5 1484
温柔的废话
温柔的废话 2020-12-04 15:08

Same as title: How to get Rails.logger printing to the console/stdout when running rspec? Eg.

Rails.logger.info \"I WANT this to go to console/s         


        
5条回答
  •  离开以前
    2020-12-04 15:39

    A solution that I like, because it keeps rspec output separate from actual rails log output, is to do the following:

    • Open a second terminal window or tab, and arrange it so that you can see both the main terminal you're running rspec on as well as the new one.
    • Run a tail command in the second window so you see the rails log in the test environment. By default this can be like $ tail -f $RAILS_APP_DIR/logs/test.log or tail -f $RAILS_APP_DIR\logs\test.log for Window users
    • Run your rspec suites

    If you are running a multi-pane terminal like iTerm, this becomes even more fun and you have rspec and the test.log output side by side.

提交回复
热议问题