| | 195 | describe "password_field (basic)" do |
|---|
| | 196 | it_should_behave_like "FakeBufferConsumer" |
|---|
| | 197 | |
|---|
| | 198 | it "should return a basic password field, but omit the value" do |
|---|
| | 199 | password_field(:name => "foo", :value => "bar").should match_tag(:input, :type => "password", :name => "foo") |
|---|
| | 200 | end |
|---|
| | 201 | |
|---|
| | 202 | it "should wrap the field in a label if the :label option is passed to the text_field" do |
|---|
| | 203 | result = password_field(:label => "LABEL" ) |
|---|
| | 204 | result.should match(/<label>LABEL<input type="password"\s*\/><\/label>/) |
|---|
| | 205 | end |
|---|
| | 206 | end |
|---|
| | 207 | |
|---|
| | 208 | describe "password_control (data bound)" do |
|---|
| | 209 | it_should_behave_like "FakeBufferConsumer" |
|---|
| | 210 | |
|---|
| | 211 | it "should take a string object and return a useful password control, but omit the value" do |
|---|
| | 212 | f = form_for :obj do |
|---|
| | 213 | password_control(:foo).should match_tag(:input, :type => "password", :name => "fake_model[foo]") |
|---|
| | 214 | end |
|---|
| | 215 | end |
|---|
| | 216 | |
|---|
| | 217 | it "should take additional attributes and use them" do |
|---|
| | 218 | form_for :obj do |
|---|
| | 219 | password_control(:foo, :bar => "7").should match_tag(:input, :type => "password", :name => "fake_model[foo]", :bar => "7") |
|---|
| | 220 | end |
|---|
| | 221 | end |
|---|
| | 222 | |
|---|
| | 223 | it "should wrap the text_control in a label if the :label option is passed in" do |
|---|
| | 224 | form_for :obj do |
|---|
| | 225 | _buffer << password_control(:foo, :label => "LABEL") |
|---|
| | 226 | end |
|---|
| | 227 | _buffer.should match(/<label>LABEL<input/) |
|---|
| | 228 | res = _buffer.scan(/<[^>]*>/) |
|---|
| | 229 | res[2].should_not match_tag(:input, :label => "LABEL") |
|---|
| | 230 | end |
|---|
| | 231 | end |
|---|
| | 232 | |
|---|