Simply Rails 2 Chapter 6 assert_select
I bought the book and been following and liking it so far! But then I hit a wall...
Trying to run all the 5 tests (13 assertions) results in the assert_select failing with
This is what my new.html.erb looks like:
Expected at least 3 elements matching "form p", found 0.
<false> is not true.
And this is the part of the test that fails:
<%= error_messages_for 'story' %>
<% form_for @story do |f| %>
<%= f.text_field :name %>
<%= f.text_field :link %>
<%= submit_tag %>
<% end %>
assert_select "form p", :count => 3
Finally, this is what the page source looks like:
I tried googling a bit and only advice I found was to re-create the test and/or new.html.erb file(s) and make sure they're saved as UTF-8. One was, other wasnt, so I saved them both as UTF-8 but unfortunately this did not help. Any ideas how to get the test to pass?
<form action="/stories" class="new_story" id="new_story" method="post"><div style="margin:0;padding:0"><input name="authenticity_token" type="hidden" value="DDY3863fJMhFT3QypnQMOVegpzgpsmC4n5Qd8REe4Mo=" /></div>
<input id="story_name" name="story[name]" size="30" type="text" />
<input id="story_link" name="story[link]" size="30" type="text" />
<input name="commit" type="submit" value="Save changes" />