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.
Alain R. (Guest)
on 2005-12-20 21: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
Duane J. (Guest)
on 2005-12-20 22:00
(Received via mailing list)
On Dec 20, 2005, at 12:16 PM, Alain R. 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 J.
(canadaduane)
http://blog.inquirylabs.com/
Alain R. (Guest)
on 2005-12-21 00: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.