Forum: Ruby on Rails printing/logging during tests

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
0091f92762685860109bbcb02edfdf27?d=identicon&s=25 Alain Ravet (Guest)
on 2005-12-20 20:23
(Received via mailing list)
Hi all,


I'm trying to output some info to see what's happening in a controller
during functional tests.
Problem: 'print' only works in the test code, but not in the production
code that's being called by the tests.

Example:

In FooControllerTest:

    def test_list
      print "1: starting"               <<----- WORKS FINE
      get :list
    end


In FooController

    def list
        print "2: inside"     		<<----- DOESN'T WORK
        logger.error "2: inside too"     <<----- DOESN'T WORK : nothing
reached test.log
        ...
    end



Any idea?


Alain
D8cb8c8cd40ddf0cd05241443a591868?d=identicon&s=25 Duane Johnson (Guest)
on 2005-12-20 21:00
(Received via mailing list)
On Dec 20, 2005, at 12:16 PM, Alain Ravet wrote:

> In FooControllerTest:
>        print "2: inside"     		<<----- DOESN'T WORK
>        logger.error "2: inside too"     <<----- DOESN'T WORK :
> nothing reached test.log
>        ...
>    end
>
>

Hmm, strange that you're not seeing anything inside of test.log.  An
alternative that I use for this sort of thing is STDERR <<, e.g.:

STDERR << "2: inside\n"

Duane Johnson
(canadaduane)
http://blog.inquirylabs.com/
B45eab4f18aa1bb2a44d6e657531a642?d=identicon&s=25 Alain Ravet (aravet)
on 2005-12-20 23:52
Duane

   > Hmm, strange that you're not seeing anything inside of test.log.

Oups. it was not the case actually: I hadn't noticed a 'before_filter'
that prevented the spyed - *1 - code from being executed

Thanks for your patience

Alain - my_face_isâ??so_red - Ravet.


*1: I'm at war with bad code, so I can spy as much as I want.
This topic is locked and can not be replied to.