Topic: Using fixture names
I've been trying to use dynamic fixture names to make my tests a but less brittle, but it's just not working.
I have a fixture called 'galleries' with a couple of entries in it; 'gallery_with_update' and 'not_visible_gallery'..
According to the agile web dev book, this should work..
require File.dirname(__FILE__) + '/../test_helper'
class GalleryTest < Test::Unit::TestCase
@gallery = Gallery.find(1)
assert_kind_of Gallery, @gallery
assert_equal @gallery_with_update.id, @gallery.id
It works if I change @gallery_with_update.id back to 1, but like this, when I run the test, I get this error:
Loaded suite test/unit/gallery_test
Finished in 0.080633 seconds.
RuntimeError: Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id
What am I doing wrong? I've tried all sorts of variations to see if it would work, but no luck. According to the book, @galleries["gallery_with_update"] should also do the same thing, but it doesnt work either..
thanks for any help..
Last edited by idlefingers (2006-07-11 11:02:18)