Skip to content

Commit

Permalink
Switch to mini_mime gem from mime-types
Browse files Browse the repository at this point in the history
  • Loading branch information
Fryguy committed Jun 28, 2017
1 parent 44e6cdf commit d2828c5
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
2 changes: 1 addition & 1 deletion capybara.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Expand Down
4 changes: 2 additions & 2 deletions gemfiles/Gemfile.base-versions
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ 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 'mini_mime', '~> 0.1.3'
gem 'addressable', '< 2.4.0' # 2.4.0 allows require 'addressable' previous don't
gem 'json', '< 2.0'
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'
gem 'term-ansicolor', '< 1.4.0'
3 changes: 1 addition & 2 deletions gemfiles/Gemfile.ruby-19
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ source 'https://rubygems.org'
gem 'bundler', '~> 1.1'
gemspec path: '..'

gem 'mime-types', '< 3.0'
gem 'mini_mime', '~> 0.1.3'
gem 'xpath', :git => 'git://github.com/teamcapybara/xpath.git'

gem 'term-ansicolor', '< 1.4.0'
Expand All @@ -12,4 +12,3 @@ 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+
2 changes: 1 addition & 1 deletion lib/capybara/rack_test/driver.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true
require 'rack/test'
require 'rack/utils'
require 'mime/types'
require 'mini_mime'
require 'nokogiri'
require 'cgi'

Expand Down
4 changes: 1 addition & 3 deletions lib/capybara/rack_test/form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d2828c5

Please sign in to comment.