1
0
Fork 0
mirror of https://github.com/teamcapybara/capybara.git synced 2022-11-09 12:08:07 -05:00

Test that demonstrates lack of support for 'multiple' attribute in input tags, see https://github.com/jnicklas/capybara/issues/778

This commit is contained in:
Jarl Friis 2012-09-03 10:33:00 +02:00
parent 3a85729e39
commit 155b9fcf79
3 changed files with 18 additions and 4 deletions

View file

@ -0,0 +1 @@
ThisIsTheOtherTestFile

View file

@ -3,6 +3,7 @@ shared_examples_for "attach_file" do
describe "#attach_file" do
before do
@test_file_path = File.expand_path('../fixtures/test_file.txt', File.dirname(__FILE__))
@another_test_file_path = File.expand_path('../fixtures/another_test_file.txt', File.dirname(__FILE__))
@test_jpg_file_path = File.expand_path('../fixtures/capybara.jpg', File.dirname(__FILE__))
@session.visit('/form')
end
@ -52,10 +53,20 @@ shared_examples_for "attach_file" do
end
it "should not break when using HTML5 multiple file input" do
@session.attach_file "Multiple Documents", @test_file_path
@session.attach_file "Multiple Documents", [@test_file_path]
@session.click_button('Upload Multiple')
@session.body.should include(">1 |")#number of files
@session.body.should include(File.read(@test_file_path))
end
it "should not break when using HTML5 multiple file input uploading multiple files" do
@session.attach_file "Multiple Documents", [@test_file_path, @another_test_file_path]
@session.click_button('Upload Multiple')
@session.body.should include(">2 |")#number of files
@session.body.should include(File.read(@test_file_path))
@session.body.should include(File.read(@another_test_file_path))
end
end
context "with a locator that doesn't exist" do

View file

@ -127,9 +127,11 @@ class TestApp < Sinatra::Base
post '/upload_multiple' do
begin
buffer = []
buffer << "Content-type: #{params[:form][:multiple_documents][0][:type]}"
buffer << "File content: #{params[:form][:multiple_documents][0][:tempfile].read}"
buffer = ["#{params[:form][:multiple_documents].size}"]
params[:form][:multiple_documents].each do |doc|
buffer << "Content-type: #{doc[:type]}"
buffer << "File content: #{doc[:tempfile].read}"
end
buffer.join(' | ')
rescue
'No files uploaded'