J'essaie d'écrire des spécifications pour la vue posts/show.html.erb d'une application simple que je prépare pour apprendre rspec. Je suis un peu perplexe en essayant de comprendre d'où vient l'extra "% 2F". Des idées?Random "% 2F" dans la spécification pour vérifier l'existence d'un formulaire de commentaire
Ma spec ...
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
La sortie de spécification avec le 2F% supplémentaire ...
'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:
Je ne pense pas. L'objet de publication n'est-il pas configuré dans mon bloc before (: each), qui ne spécifie pas d'identifiant spécifique dans l'appel de mock_model? D'ailleurs, je pense que% 2F est un slash ... pas un espace. Hrm ... –
Oh, vous avez raison sur le% 2F. –