Created
August 21, 2008 02:05
-
-
Save bryansray/6482 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
# My spec ... | |
it "should not put the value of the last <option> attributes in to the attributes of the select tag" do | |
content = select(:collection => %w(one two three), :selected => 'three') | |
content.should_not match_tag(:select, :value => "three", :selected => "selected") | |
end | |
def options(col, text_meth, value_meth, attrs, sel, b) | |
options = [b] + col.map do |item| | |
value = item.send(value_meth) | |
opt_attrs = {:value => value} | |
opt_attrs.merge!(:selected => "selected") if value == sel | |
tag(:option, item.send(text_meth), opt_attrs) | |
end | |
options.join | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment