题
我试图写一个简单的应用程序,我将一起学习rspec的的职位/ show.html.erb查看规格。我有点此刻在试图找出其中额外的“%2F”是来自难住了。任何想法?
我的规格...
it "should render a form to add a comment" do
render "posts/show.html.erb"
response.should have_selector("form[method=post]", :action => post_comments_path([@post, @comment])) do |form|
form.should have_selector("input[name='comment[author_name]']")
form.should have_selector("textarea[name='comment[body]']")
form.should have_selector("input[type=submit]")
end
end
与额外%2F该规范输出...
'posts/show.html.erb should render a form to add a comment' FAILED
expected following output to contain a <form[method=post] action='/posts/1001%2F/comments'/> tag:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html><body>
<p>#[Post:0x1288146 @name="Post_1001"]
#[Post:0x1288146 @name="Post_1001"]
#[Post:0x1288146 @name="Post_1001"]
Comments<br></p>
<form action="/posts/1001/comments" class="new_comment" id="new_comment" method="post">
</form>
</body></html>
./spec/views/posts/show.html.erb_spec.rb:13:
解决方案
什么是您的form_for看起来像在再培训局? Rspec的可表现为奇怪,在轨道正常工作某些路由方案。
您正在使用什么版本的RSpec的(和你最近更新)?
你为什么SPEC-ING的意见,而不是只用黄瓜?
其他提示
请问你后ID以某种方式有它的尾部空间?
不隶属于 StackOverflow