Why not test by creating comments - bypass the comments fixtures all
together?

def test_should_be_able_to_have_many_comments
  blog = blog.create!(valid_blog_attributes)
  assert_difference "blog.comments" do
    blog.comments.create!(valid_comment_attributes)
  end
end

what version of rails are you using?

On Apr 16, 10:46 am, Joshua Muheim <[email protected]>
wrote:
> It seems that the fixtures are not correct (not complete). When I
> specify the commentable_type and _id, it works:
>
>   commentable_type: "Blog"
>   commentable_id: 1
>
> Why is that? I'd like to put the fixtures as loose as possible into the
> database and then hardwire them to the needed other objects in each
> test, so for the blog_test.rb I wanted to do:
>
>   def setup
>     @valid_blog = Blog.new(valid_blog_attributes)
>     @valid_blog.comments << comments
>   end
>
> ...and I hoped that this would automatically set the commentable_type
> and _id to the needed values then.
>
> But this doesn't seem so. So I guess I have to hardwire the stuff all in
> the fixtures... Or are there other, better ways to achieve better
> dynamics?
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to