Created
February 16, 2009 10:23
-
-
Save justinfrench/65108 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 1. add this to formtastic_spec.rb inside the ":as => :select" describe block | |
it 'should have one option with a "selected" attribute' do | |
output_buffer.should have_tag('form li select option[@selected]', :count => 2) # the 2 is intentional | |
end | |
# 2. run the specs | |
expected | |
<form class="formtastic post" action="/posts" method="post" id="new_post"><li class="select optional" id="post_author_id_input"><label for="post_author_id">Author</label><select name="post[author_id]" id="post_author_id"><option value="37">Fred Smith</option> | |
<option selected="selected" value="42">Bob Rock</option></select> | |
</li></form> | |
to have 2 elements matching "form li select option[@selected]", but found 1 | |
# 3. change the spec to only look for one | |
it 'should have one option with a "selected" attribute' do | |
output_buffer.should have_tag('form li select option[@selected]', :count => 1) | |
end | |
# 4. run the specs, they pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment