| | 468 | describe "file_field (basic)" do |
|---|
| | 469 | it_should_behave_like "FakeBufferConsumer" |
|---|
| | 470 | |
|---|
| | 471 | it "should return a basic file field based on the values passed in" do |
|---|
| | 472 | file_field(:name => "foo", :value => "bar").should match_tag( :input, :type => "file", :name => "foo", :value => "bar") |
|---|
| | 473 | end |
|---|
| | 474 | |
|---|
| | 475 | it "should wrap the field in a label if the :label option is passed to the file_field" do |
|---|
| | 476 | result = file_field(:label => "LABEL" ) |
|---|
| | 477 | result.should match(/<label>LABEL<input type="file"\s*\/><\/label>/) |
|---|
| | 478 | end |
|---|
| | 479 | end |
|---|
| | 480 | |
|---|
| | 481 | describe "file_control (data bound)" do |
|---|
| | 482 | it_should_behave_like "FakeBufferConsumer" |
|---|
| | 483 | |
|---|
| | 484 | it "should take a string object and return a useful file control" do |
|---|
| | 485 | f = form_for :obj do |
|---|
| | 486 | file_control(:foo).should match_tag(:input, :type => "file", :name => "fake_model[foo]", :value => "foowee") |
|---|
| | 487 | end |
|---|
| | 488 | end |
|---|
| | 489 | |
|---|
| | 490 | it "should take additional attributes and use them" do |
|---|
| | 491 | form_for :obj do |
|---|
| | 492 | file_control(:foo, :bar => "7").should match_tag(:input, :type => "file", :name => "fake_model[foo]", :value => "foowee", :bar => "7") |
|---|
| | 493 | end |
|---|
| | 494 | end |
|---|
| | 495 | |
|---|
| | 496 | it "should wrap the file_control in a label if the :label option is passed in" do |
|---|
| | 497 | form_for :obj do |
|---|
| | 498 | _buffer << text_control(:foo, :label => "LABEL") |
|---|
| | 499 | end |
|---|
| | 500 | _buffer.should match(/<label>LABEL<input/) |
|---|
| | 501 | res = _buffer.scan(/<[^>]*>/) |
|---|
| | 502 | res[2].should_not match_tag(:input, :label => "LABEL") |
|---|
| | 503 | end |
|---|
| | 504 | end |
|---|
| | 505 | |
|---|