Forum: Ruby on Rails Code works in console but fails test?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
3f91cf60c92b20940674ebdeb46f6582?d=identicon&s=25 Brian Smith (praufet)
on 2007-08-02 16:35
(Received via mailing list)
So I have message model and each user has many messages. When I run
user.messages in the console it returns correctly, however in the test
it returns and empty collection? Any thoughts. All the sql is being
generate correctly, I checked the log. Here's a pastie with the code
in question.
40db9e75b3f5899258e3bdc0c9210154?d=identicon&s=25 Conrad Taylor (Guest)
on 2007-08-02 16:43
(Received via mailing list)
Hi, please post the exact statement that you're typing in the console.
3f91cf60c92b20940674ebdeb46f6582?d=identicon&s=25 Brian Smith (praufet)
on 2007-08-02 17:06
(Received via mailing list)
u = User.find :first

the output is three
D69d23d8e811e8ab2a8593380d6ede63?d=identicon&s=25 Jeff Emminger (jemminger)
on 2007-08-03 04:17
(Received via mailing list)
tests are run against the test database, so it will be empty unless
you create some messages for your user in fixtures or otherwise.
This topic is locked and can not be replied to.