Hi all
I'm trying to write good unit tests. Here's part of my blog_test.rb:
--- blog_test.rb:
require File.dirname(__FILE__) + '/../test_helper'
class BlogTest < Test::Unit::TestCase fixtures :blogs, :comments
def setup @valid_blog = Blog.new(valid_blog_attributes) end
def test_should_be_able_to_have_many_comments @valid_blog.comments = {} assert_valid @valid_blog
comments.each do |comment| @valid_blog.comments << comment assert_not_nil @valid_blog.comments assert_valid @valid_blog end end end
--- comments.yml:
first_comment: id: 1 body: "Dies ist der Inhalt des ersten Kommentars"
second_comment: id: 2 body: "Dies ist der Inhalt des zweiten Kommentars"
The Comment model is :polymorphic => true, :as => :commentable.
As we can see there are two comments available in the fixtures, but in when running the test_should_be_able_to_have_many_comments test, there are none!
puts comments.size
returns 0 all the time! Why aren't they available?
Thanks a lot for help. Josh