0

rspec を学ぶためにまとめている単純なアプリケーションの posts/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:
4

2 に答える 2

0

form_for は erb でどのように見えますか? Rspec は、レールでは正常に機能する特定のルーティング シナリオで奇妙な動作をすることがあります。

どのバージョンの rspec を使用していますか (そして最近更新しましたか)?

きゅうりを使用するだけでなく、ビューを仕様化するのはなぜですか?

于 2009-08-04T01:08:17.433 に答える
0

投稿 ID の末尾に何らかのスペースが含まれていますか?

于 2009-08-03T05:10:37.453 に答える