I recently started learning ruby on rails. I completed the weblog walkthru(links below) and want to make tests for it. I took this functional testing from the video version of the weblog demo. Now i want to make this testing work for the netbeans edition, which actually is structured differently in terms of how the comments relates to the post. From what I gathered, in the netbeans version, all comment views are done through the posts views. Now this test method needs to be modified to accomodate for that. How would I create the post object with a comment also? I dont know how objects work in Ruby. Like how to instantiate and such.
test "should create comment and redirect to post without javascript" do
p= Post.create!(:title => 'hello',:body => 'world')
post :create, :post_id => p.id, :comment => {:body =>'nice!'}
assert_redirected_to post_url(p)
assert_equal 'nice!',p.comments.first.body
end