Post
在我的Rails论坛应用程序中失败。
岗位
我正在尝试此操作,但它给了我错误的URI错误:
Error:
PostsNewTest#test_make_a_new_post_with_invalid_title:
URI::InvalidURIError: bad URI(is not URI?): http://www.example.com:80{:params=>{:post=>{:title=>"", :body=>"body", :user_id=>762146111, :category=>"general/announcements"}}}
test/integration/posts_new_test.rb:31:in `block (2 levels) in <class:PostsNewTest>'
test/integration/posts_new_test.rb:30:in `block in <class:PostsNewTest>'
这是我尝试的,我花了很多时间来让它工作,但我只是不知道如何正确地做它。如果有人能帮我把事情做好,我会很高兴的:
test 'make a new post with invalid title' do
log_in_as(@user_archer)
get new_post_path category: @valid_category
assert_no_difference 'Post.count' do
post params: { post: {title: @invalid_title,
body: @valid_body,
user_id: @valid_user_id ,
category: @valid_category}}
end
end
我没有得到的路线正确的地方张贴,因为它不是一个命名的路线,如
post_a_Post_path
编辑:额外的问题这是属于集成测试还是应该是模型测试的一部分
岗位
?