RSpec and getting puts or logger.info to work
When I'm running my specs like "rspec ." from the command line, I can see puts or logger.info in the console, if i call that code in my spec. However, if the call to logger.info or puts is in my controller whic开发者_如何学JAVAh I'm testing, it doesn't output to the test.log file or the console window.
I'm using RSpec 2 and Rails 3.0.4
Also, this is a refinerycms site, but we have a couple of controllers external to the Refinery CMS we are trying to test. When I do a puts or logger.info in a normal site, it seems to work fine, even running RSpec.
Thanks.
Okay so we finally figured this out.
The issue is that Refinery requires a default user to be created or it does not let you hit front end pages. When you first fire it up, it prompts the user to create a default admin login. So when we were running our tests, our code was never getting hit. Refinery was redirecting the "browser" during test time to the "create a first user" page.
We created a seed with a default user and then everything worked again. So the issue was never that doing a "puts" or "logger.info" didn't work in refinery or rspec. It was that during testing, we never were getting to our controller.
精彩评论