diff --git a/README.md b/README.md index ede725d11..154cd40fb 100644 --- a/README.md +++ b/README.md @@ -88,7 +88,7 @@ Capybara requires Ruby 1.9.3 or later. To install, add this line to your gem 'capybara' ``` -**Note:** If using Ruby < 2.0 you will also need to limit the version of mime-types to < 3.0 and the version of rack to < 2.0 +**Note:** If using Ruby < 2.0 you will also need to limit the version of rack to < 2.0 If the application that you are testing is a Rails app, add this line to your test helper file: diff --git a/capybara.gemspec b/capybara.gemspec index 25fae60f0..937ebfec1 100644 --- a/capybara.gemspec +++ b/capybara.gemspec @@ -22,7 +22,7 @@ Gem::Specification.new do |s| s.summary = "Capybara aims to simplify the process of integration testing Rack applications, such as Rails, Sinatra or Merb" s.add_runtime_dependency("nokogiri", [">= 1.3.3"]) - s.add_runtime_dependency("mime-types", [">= 1.16"]) + s.add_runtime_dependency("mini_mime", [">= 0.1.3"]) s.add_runtime_dependency("rack", [">= 1.0.0"]) s.add_runtime_dependency("rack-test", [">= 0.5.4"]) s.add_runtime_dependency("xpath", ["~> 2.0"]) diff --git a/gemfiles/Gemfile.base-versions b/gemfiles/Gemfile.base-versions index 4e3441580..a99211257 100644 --- a/gemfiles/Gemfile.base-versions +++ b/gemfiles/Gemfile.base-versions @@ -11,7 +11,6 @@ gem 'nokogiri', '= 1.3.3' gem 'rspec', '= 2.2.0' gem 'cucumber', '= 0.10.5' gem 'tins', '= 1.6.0' # 1.7.0 requires ruby 2.0 -gem 'mime-types', '<3.0' # 3.0 require ruby 2.0 gem 'addressable', '< 2.4.0' # 2.4.0 allows require 'addressable' previous don't gem 'json', '< 2.0' gem 'rake', '< 11.0' @@ -19,4 +18,4 @@ gem 'rake', '< 11.0' # We cannot test against older versions of selenium-webdriver without # installing older compatible Firefox versions. gem 'selenium-webdriver', '< 3.0.0' -gem 'term-ansicolor', '< 1.4.0' \ No newline at end of file +gem 'term-ansicolor', '< 1.4.0' diff --git a/gemfiles/Gemfile.ruby-19 b/gemfiles/Gemfile.ruby-19 index 12a0e9325..894c5d90c 100644 --- a/gemfiles/Gemfile.ruby-19 +++ b/gemfiles/Gemfile.ruby-19 @@ -3,7 +3,6 @@ source 'https://rubygems.org' gem 'bundler', '~> 1.1' gemspec path: '..' -gem 'mime-types', '< 3.0' gem 'xpath', :git => 'git://github.com/teamcapybara/xpath.git' gem 'term-ansicolor', '< 1.4.0' @@ -12,4 +11,4 @@ gem 'tins', '< 1.7.0' # 1.7.0 requires ruby 2.0 gem 'selenium-webdriver', '< 3.0.0' # 3.0 requires ruby 2.0 gem 'addressable', '< 2.5.0' # 2.5 requires public_suffix which requires ruby 2.0 gem 'nokogiri', '< 1.7.0' # 1.7 requires ruby 2.1+ -gem 'rack', '<2.0' # 2.0 requires ruby 2.2+ \ No newline at end of file +gem 'rack', '<2.0' # 2.0 requires ruby 2.2+ diff --git a/lib/capybara/rack_test/driver.rb b/lib/capybara/rack_test/driver.rb index 013406ed1..c984f7b79 100644 --- a/lib/capybara/rack_test/driver.rb +++ b/lib/capybara/rack_test/driver.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true require 'rack/test' require 'rack/utils' -require 'mime/types' +require 'mini_mime' require 'nokogiri' require 'cgi' diff --git a/lib/capybara/rack_test/form.rb b/lib/capybara/rack_test/form.rb index 86db8b9be..a1b82b5a5 100644 --- a/lib/capybara/rack_test/form.rb +++ b/lib/capybara/rack_test/form.rb @@ -42,9 +42,7 @@ def params(button) if (value = field['value']).to_s.empty? NilUploadedFile.new else - types = MIME::Types.type_for(value) - content_type = types.sort_by.with_index { |type, idx| [type.obsolete? ? 1 : 0, idx] }.first.to_s - Rack::Test::UploadedFile.new(value, content_type) + Rack::Test::UploadedFile.new(value, MiniMime.lookup_by_filename(value).content_type) end merge_param!(params, field['name'].to_s, file) else