Apparently the first time I posted this, it was tacked onto the end of
another thread. Please pardon my repost. Won’t happen again.
Howdy. I’m just getting into Rails, and really enjoying it! I’m coming
from the .NET world, so I’ll embarrassedly admit that I’m running it on
winXP and even using SQLServer (for now, may switch to mysql soon).
Hopefully someday I’ll feel competent enough on my mac to work there,
but
one new thing at a time!
Anyway, I am trying to be a good programmer and use TDD, but am having a
problem with a simple test, mostly copied from the examples on:
http://ar.rubyonrails.org/classes/Fixtures.html
I generated my model classes and even got the scaffold working (ooh,
bad!
not TDD!!). I was starting out messing with unit tests and fixtures,
and
was taking baby steps. Ran into a hitch when it was saying that my
fixture
variable was nil:
require File.dirname(FILE) + ‘/…/test_helper’
class MessageTest < Test::Unit::TestCase
fixtures :messages, :tags, :messages_tags
def setup
@message = Message.find(1)
end
def test_create
assert_kind_of Message, @message
assert_not_nil @messages
assert_equal @messages[“peace_message”].title, @message.title
end
end
The three fixtures exist (messages, tags, messages_tags) and have data.
Brute force tests (assert_equal “my message title”, @message.title)
pass.
But the @messages[“peace_message”][“title”] returns an error. I added
the
assert_not_nil call and indeed, that fails. It seems like it should
automatically exist? What am I doing wrong?
Thanks for any help!
Brian