vagrant-unbundled 2.2.18.0 → 2.2.19.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (176) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +15 -0
  3. data/Gemfile.lock +6 -6
  4. data/contrib/zsh/generate_zsh_completion.rb +2 -2
  5. data/lib/vagrant/errors.rb +8 -0
  6. data/plugins/commands/upload/command.rb +1 -1
  7. data/plugins/guests/atomic/guest.rb +1 -1
  8. data/plugins/guests/coreos/cap/configure_networks.rb +65 -0
  9. data/plugins/guests/darwin/cap/mount_smb_shared_folder.rb +6 -3
  10. data/plugins/guests/suse/cap/halt.rb +5 -1
  11. data/plugins/guests/windows/cap/rsync.rb +5 -1
  12. data/plugins/hosts/darwin/cap/path.rb +4 -0
  13. data/plugins/hosts/darwin/cap/version.rb +23 -0
  14. data/plugins/hosts/darwin/plugin.rb +5 -0
  15. data/plugins/hosts/windows/cap/ssh.rb +1 -1
  16. data/plugins/providers/virtualbox/action/network.rb +39 -2
  17. data/plugins/provisioners/chef/cap/freebsd/chef_installed.rb +5 -3
  18. data/plugins/provisioners/chef/cap/linux/chef_installed.rb +5 -3
  19. data/plugins/provisioners/chef/cap/omnios/chef_installed.rb +7 -5
  20. data/plugins/provisioners/chef/cap/windows/chef_installed.rb +3 -2
  21. data/templates/locales/en.yml +25 -0
  22. data/vagrant.gemspec +1 -1
  23. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/CONTRIBUTING.md +23 -0
  24. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/CONTRIBUTORS.md +140 -0
  25. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/LICENSE.md +20 -0
  26. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/README.md +492 -0
  27. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/data/cacert.pem +3232 -0
  28. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/excon.gemspec +45 -0
  29. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/connection.rb +599 -0
  30. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/constants.rb +172 -0
  31. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/error.rb +229 -0
  32. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/extensions/uri.rb +34 -0
  33. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/headers.rb +85 -0
  34. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/instrumentors/logging_instrumentor.rb +48 -0
  35. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/instrumentors/standard_instrumentor.rb +21 -0
  36. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/middlewares/base.rb +31 -0
  37. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/middlewares/capture_cookies.rb +32 -0
  38. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/middlewares/decompress.rb +44 -0
  39. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/middlewares/escape_path.rb +12 -0
  40. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/middlewares/expects.rb +25 -0
  41. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/middlewares/idempotent.rb +57 -0
  42. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/middlewares/instrumentor.rb +49 -0
  43. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/middlewares/mock.rb +61 -0
  44. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/middlewares/redirect_follower.rb +87 -0
  45. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/middlewares/response_parser.rb +16 -0
  46. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/pretty_printer.rb +39 -0
  47. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/response.rb +234 -0
  48. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/socket.rb +297 -0
  49. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/ssl_socket.rb +194 -0
  50. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/test/plugin/server/exec.rb +26 -0
  51. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/test/plugin/server/puma.rb +23 -0
  52. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/test/plugin/server/unicorn.rb +40 -0
  53. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/test/plugin/server/webrick.rb +26 -0
  54. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/test/server.rb +106 -0
  55. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/unix_socket.rb +42 -0
  56. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/utils.rb +143 -0
  57. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/version.rb +4 -0
  58. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon.rb +255 -0
  59. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/MIT-LICENSE +20 -0
  60. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/README.md +122 -0
  61. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/base.rb +289 -0
  62. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/cache.rb +113 -0
  63. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/cache_file.rb +36 -0
  64. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/cascade.rb +56 -0
  65. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/chain.rb +130 -0
  66. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/fallbacks.rb +97 -0
  67. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/flatten.rb +118 -0
  68. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/gettext.rb +85 -0
  69. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/interpolation_compiler.rb +123 -0
  70. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/key_value.rb +206 -0
  71. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/memoize.rb +54 -0
  72. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/metadata.rb +71 -0
  73. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/pluralization.rb +55 -0
  74. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/simple.rb +108 -0
  75. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/transliterator.rb +108 -0
  76. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend.rb +21 -0
  77. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/config.rb +165 -0
  78. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/core_ext/hash.rb +59 -0
  79. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/exceptions.rb +111 -0
  80. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/gettext/helpers.rb +75 -0
  81. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/gettext/po_parser.rb +329 -0
  82. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/gettext.rb +28 -0
  83. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/interpolate/ruby.rb +39 -0
  84. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/locale/fallbacks.rb +99 -0
  85. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/locale/tag/parents.rb +24 -0
  86. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/locale/tag/rfc4646.rb +74 -0
  87. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/locale/tag/simple.rb +39 -0
  88. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/locale/tag.rb +28 -0
  89. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/locale.rb +8 -0
  90. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/middleware.rb +17 -0
  91. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/basics.rb +60 -0
  92. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/defaults.rb +52 -0
  93. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/interpolation.rb +163 -0
  94. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/link.rb +66 -0
  95. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/localization/date.rb +117 -0
  96. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/localization/date_time.rb +103 -0
  97. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/localization/procs.rb +117 -0
  98. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/localization/time.rb +103 -0
  99. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/localization.rb +19 -0
  100. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/lookup.rb +81 -0
  101. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/pluralization.rb +35 -0
  102. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/procs.rb +60 -0
  103. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests.rb +14 -0
  104. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/version.rb +5 -0
  105. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n.rb +415 -0
  106. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/Code-of-Conduct.md +73 -0
  107. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/Contributing.md +132 -0
  108. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/History.md +269 -0
  109. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/Licence.md +25 -0
  110. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/Manifest.txt +31 -0
  111. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/README.rdoc +194 -0
  112. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/Rakefile +270 -0
  113. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/type/columnar.rb +57 -0
  114. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/type.rb +634 -0
  115. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/types/_columnar.rb +137 -0
  116. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/types/cache.rb +58 -0
  117. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/types/columnar.rb +3 -0
  118. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/types/container.rb +96 -0
  119. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/types/deprecations.rb +36 -0
  120. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/types/full.rb +19 -0
  121. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/types/loader.rb +159 -0
  122. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/types/logger.rb +37 -0
  123. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/types/registry.rb +90 -0
  124. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/types.rb +233 -0
  125. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime-types.rb +3 -0
  126. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/test/bad-fixtures/malformed +9 -0
  127. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/test/fixture/json.json +1 -0
  128. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/test/fixture/old-data +9 -0
  129. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/test/fixture/yaml.yaml +55 -0
  130. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/test/minitest_helper.rb +11 -0
  131. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/test/test_mime_type.rb +621 -0
  132. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/test/test_mime_types.rb +169 -0
  133. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/test/test_mime_types_cache.rb +118 -0
  134. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/test/test_mime_types_class.rb +159 -0
  135. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/test/test_mime_types_lazy.rb +49 -0
  136. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/test/test_mime_types_loader.rb +32 -0
  137. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/Code-of-Conduct.md +75 -0
  138. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/Contributing.md +241 -0
  139. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/History.md +494 -0
  140. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/Licence.md +24 -0
  141. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/Manifest.txt +34 -0
  142. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/README.md +73 -0
  143. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/Rakefile +155 -0
  144. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/data/content_type_mime.db +878 -0
  145. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/data/ext_mime.db +1198 -0
  146. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/data/mime-types.json +1 -0
  147. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/data/mime.content_type.column +2376 -0
  148. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/data/mime.docs.column +2376 -0
  149. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/data/mime.encoding.column +2376 -0
  150. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/data/mime.flags.column +2376 -0
  151. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/data/mime.friendly.column +2376 -0
  152. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/data/mime.pext.column +2376 -0
  153. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/data/mime.use_instead.column +2376 -0
  154. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/data/mime.xrefs.column +2376 -0
  155. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/lib/mime/types/data.rb +21 -0
  156. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/lib/mime-types-data.rb +3 -0
  157. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/application.yaml +17254 -0
  158. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/audio.yaml +1716 -0
  159. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/chemical.yaml +71 -0
  160. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/conference.yaml +9 -0
  161. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/drawing.yaml +15 -0
  162. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/font.yaml +65 -0
  163. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/image.yaml +1251 -0
  164. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/message.yaml +200 -0
  165. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/model.yaml +390 -0
  166. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/multipart.yaml +179 -0
  167. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/provisional-standard-types.yaml +129 -0
  168. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/text.yaml +1166 -0
  169. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/video.yaml +1121 -0
  170. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/world.yaml +8 -0
  171. data/vendor/bundle/ruby/3.0.0/specifications/excon-0.89.0.gemspec +58 -0
  172. data/vendor/bundle/ruby/3.0.0/specifications/i18n-1.8.11.gemspec +32 -0
  173. data/vendor/bundle/ruby/3.0.0/specifications/mime-types-3.4.1.gemspec +63 -0
  174. data/vendor/bundle/ruby/3.0.0/specifications/mime-types-data-3.2021.1115.gemspec +54 -0
  175. data/version.txt +1 -1
  176. metadata +157 -4
@@ -0,0 +1,621 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "mime/types"
4
+ require "minitest_helper"
5
+
6
+ describe MIME::Type do
7
+ def mime_type(content_type)
8
+ MIME::Type.new(content_type) { |mt| yield mt if block_given? }
9
+ end
10
+
11
+ let(:x_appl_x_zip) {
12
+ mime_type("x-appl/x-zip") { |t| t.extensions = %w[zip zp] }
13
+ }
14
+ let(:text_plain) { mime_type("text/plain") }
15
+ let(:text_html) { mime_type("text/html") }
16
+ let(:image_jpeg) { mime_type("image/jpeg") }
17
+ let(:application_javascript) {
18
+ mime_type("application/javascript") do |js|
19
+ js.friendly("en" => "JavaScript")
20
+ js.xrefs = {
21
+ "rfc" => %w[rfc4239 rfc4239],
22
+ "template" => %w[application/javascript]
23
+ }
24
+ js.encoding = "8bit"
25
+ js.extensions = %w[js sj]
26
+ js.registered = true
27
+ end
28
+ }
29
+ let(:text_x_yaml) {
30
+ mime_type("text/x-yaml") do |yaml|
31
+ yaml.extensions = %w[yaml yml]
32
+ yaml.encoding = "8bit"
33
+ yaml.friendly("en" => "YAML Structured Document")
34
+ end
35
+ }
36
+ let(:text_x_yaml_with_docs) {
37
+ text_x_yaml.dup.tap do |yaml|
38
+ yaml.docs = "Test YAML"
39
+ end
40
+ }
41
+
42
+ describe ".simplified" do
43
+ it "leaves normal types alone" do
44
+ assert_equal "text/plain", MIME::Type.simplified("text/plain")
45
+ end
46
+
47
+ it "does not remove x- prefixes by default" do
48
+ assert_equal "application/x-msword",
49
+ MIME::Type.simplified("application/x-msword")
50
+ assert_equal "x-xyz/abc", MIME::Type.simplified("x-xyz/abc")
51
+ end
52
+
53
+ it "removes x- prefixes when requested" do
54
+ assert_equal "application/msword",
55
+ MIME::Type.simplified("application/x-msword", remove_x_prefix: true)
56
+ assert_equal "xyz/abc",
57
+ MIME::Type.simplified("x-xyz/abc", remove_x_prefix: true)
58
+ end
59
+
60
+ it "lowercases mixed-case types" do
61
+ assert_equal "text/vcard", MIME::Type.simplified("text/vCard")
62
+ end
63
+
64
+ it "returns nil when the value provided is not a valid content type" do
65
+ assert_nil MIME::Type.simplified("text")
66
+ end
67
+ end
68
+
69
+ describe ".i18n_key" do
70
+ it "converts text/plain to text.plain" do
71
+ assert_equal "text.plain", MIME::Type.i18n_key("text/plain")
72
+ end
73
+
74
+ it "does not remove x-prefixes" do
75
+ assert_equal "application.x-msword",
76
+ MIME::Type.i18n_key("application/x-msword")
77
+ end
78
+
79
+ it "converts text/vCard to text.vcard" do
80
+ assert_equal "text.vcard", MIME::Type.i18n_key("text/vCard")
81
+ end
82
+
83
+ it "returns nil when the value provided is not a valid content type" do
84
+ assert_nil MIME::Type.i18n_key("text")
85
+ end
86
+ end
87
+
88
+ describe ".new" do
89
+ it "fails if an invalid content type is provided" do
90
+ exception = assert_raises MIME::Type::InvalidContentType do
91
+ MIME::Type.new("apps")
92
+ end
93
+ assert_equal 'Invalid Content-Type "apps"', exception.to_s
94
+ end
95
+
96
+ it "creates a valid content type just from a string" do
97
+ type = MIME::Type.new("text/x-yaml")
98
+
99
+ assert_instance_of MIME::Type, type
100
+ assert_equal "text/x-yaml", type.content_type
101
+ end
102
+
103
+ it "yields the content type in a block" do
104
+ MIME::Type.new("text/x-yaml") do |type|
105
+ assert_instance_of MIME::Type, type
106
+ assert_equal "text/x-yaml", type.content_type
107
+ end
108
+ end
109
+
110
+ it "creates a valid content type from a hash" do
111
+ type = MIME::Type.new(
112
+ "content-type" => "text/x-yaml",
113
+ "obsolete" => true
114
+ )
115
+ assert_instance_of MIME::Type, type
116
+ assert_equal "text/x-yaml", type.content_type
117
+ assert type.obsolete?
118
+ end
119
+
120
+ it "creates a valid content type from an array" do
121
+ type = MIME::Type.new(%w[text/x-yaml yaml yml yz])
122
+ assert_instance_of MIME::Type, type
123
+ assert_equal "text/x-yaml", type.content_type
124
+ assert_equal %w[yaml yml yz], type.extensions
125
+ end
126
+ end
127
+
128
+ describe "#like?" do
129
+ it "compares two MIME::Types on #simplified values without x- prefixes" do
130
+ assert text_plain.like?(text_plain)
131
+ refute text_plain.like?(text_html)
132
+ end
133
+
134
+ it "compares MIME::Type against string without x- prefixes" do
135
+ assert text_plain.like?(text_plain.to_s)
136
+ refute text_plain.like?(text_html.to_s)
137
+ end
138
+ end
139
+
140
+ describe "#<=>" do
141
+ it "correctly compares identical types" do
142
+ assert_equal text_plain, text_plain
143
+ end
144
+
145
+ it "correctly compares equivalent types" do
146
+ right = mime_type("text/Plain")
147
+ refute_same text_plain, right
148
+ assert_equal text_plain, right
149
+ end
150
+
151
+ it "correctly compares types that sort earlier" do
152
+ refute_equal text_html, text_plain
153
+ assert_operator text_html, :<, text_plain
154
+ end
155
+
156
+ it "correctly compares types that sort later" do
157
+ refute_equal text_plain, text_html
158
+ assert_operator text_plain, :>, text_html
159
+ end
160
+
161
+ it "correctly compares types against equivalent strings" do
162
+ assert_equal text_plain, "text/plain"
163
+ end
164
+
165
+ it "correctly compares types against strings that sort earlier" do
166
+ refute_equal text_html, "text/plain"
167
+ assert_operator text_html, :<, "text/plain"
168
+ end
169
+
170
+ it "correctly compares types against strings that sort later" do
171
+ refute_equal text_plain, "text/html"
172
+ assert_operator text_plain, :>, "text/html"
173
+ end
174
+
175
+ it "correctly compares against nil" do
176
+ refute_equal text_html, nil
177
+ assert_operator text_plain, :<, nil
178
+ end
179
+ end
180
+
181
+ describe "#ascii?" do
182
+ it "defaults to true for text/* types" do
183
+ assert text_plain.ascii?
184
+ end
185
+
186
+ it "defaults to false for non-text/* types" do
187
+ refute image_jpeg.ascii?
188
+ end
189
+ end
190
+
191
+ describe "#binary?" do
192
+ it "defaults to false for text/* types" do
193
+ refute text_plain.binary?
194
+ end
195
+
196
+ it "defaults to true for non-text/* types" do
197
+ assert image_jpeg.binary?
198
+ end
199
+ end
200
+
201
+ describe "#complete?" do
202
+ it "is true when there are extensions" do
203
+ assert text_x_yaml.complete?
204
+ end
205
+
206
+ it "is false when there are no extensions" do
207
+ refute mime_type("text/plain").complete?
208
+ end
209
+ end
210
+
211
+ describe "#content_type" do
212
+ it "preserves the original case" do
213
+ assert_equal "text/plain", text_plain.content_type
214
+ assert_equal "text/vCard", mime_type("text/vCard").content_type
215
+ end
216
+
217
+ it "does not remove x- prefixes" do
218
+ assert_equal "x-appl/x-zip", x_appl_x_zip.content_type
219
+ end
220
+ end
221
+
222
+ describe "#default_encoding" do
223
+ it "is quoted-printable for text/* types" do
224
+ assert_equal "quoted-printable", text_plain.default_encoding
225
+ end
226
+
227
+ it "is base64 for non-text/* types" do
228
+ assert_equal "base64", image_jpeg.default_encoding
229
+ end
230
+ end
231
+
232
+ describe "#encoding, #encoding=" do
233
+ it "returns #default_encoding if not set explicitly" do
234
+ assert_equal "quoted-printable", text_plain.encoding
235
+ assert_equal "base64", image_jpeg.encoding
236
+ end
237
+
238
+ it "returns the set value when set" do
239
+ text_plain.encoding = "8bit"
240
+ assert_equal "8bit", text_plain.encoding
241
+ end
242
+
243
+ it "resets to the default encoding when set to nil or :default" do
244
+ text_plain.encoding = "8bit"
245
+ text_plain.encoding = nil
246
+ assert_equal text_plain.default_encoding, text_plain.encoding
247
+ text_plain.encoding = :default
248
+ assert_equal text_plain.default_encoding, text_plain.encoding
249
+ end
250
+
251
+ it "raises a MIME::Type::InvalidEncoding for an invalid encoding" do
252
+ exception = assert_raises MIME::Type::InvalidEncoding do
253
+ text_plain.encoding = "binary"
254
+ end
255
+ assert_equal 'Invalid Encoding "binary"', exception.to_s
256
+ end
257
+ end
258
+
259
+ describe "#eql?" do
260
+ it "is not true for a non-MIME::Type" do
261
+ refute text_plain.eql?("text/plain")
262
+ end
263
+
264
+ it "is not true for a different MIME::Type" do
265
+ refute text_plain.eql?(image_jpeg)
266
+ end
267
+
268
+ it "is true for an equivalent MIME::Type" do
269
+ assert text_plain, mime_type("text/Plain")
270
+ end
271
+ end
272
+
273
+ describe "#extensions, #extensions=" do
274
+ it "returns an array of extensions" do
275
+ assert_equal %w[yaml yml], text_x_yaml.extensions
276
+ assert_equal %w[zip zp], x_appl_x_zip.extensions
277
+ end
278
+
279
+ it "sets a single extension when provided a single value" do
280
+ text_x_yaml.extensions = "yaml"
281
+ assert_equal %w[yaml], text_x_yaml.extensions
282
+ end
283
+
284
+ it "deduplicates extensions" do
285
+ text_x_yaml.extensions = %w[yaml yaml]
286
+ assert_equal %w[yaml], text_x_yaml.extensions
287
+ end
288
+ end
289
+
290
+ describe "#add_extensions" do
291
+ it "does not modify extensions when provided nil" do
292
+ text_x_yaml.add_extensions(nil)
293
+ assert_equal %w[yaml yml], text_x_yaml.extensions
294
+ end
295
+
296
+ it "remains deduplicated with duplicate values" do
297
+ text_x_yaml.add_extensions("yaml")
298
+ assert_equal %w[yaml yml], text_x_yaml.extensions
299
+ text_x_yaml.add_extensions(%w[yaml yz])
300
+ assert_equal %w[yaml yml yz], text_x_yaml.extensions
301
+ end
302
+ end
303
+
304
+ describe "#priority_compare" do
305
+ def assert_priority_less(left, right)
306
+ assert_equal(-1, left.priority_compare(right))
307
+ end
308
+
309
+ def assert_priority_same(left, right)
310
+ assert_equal 0, left.priority_compare(right)
311
+ end
312
+
313
+ def assert_priority_more(left, right)
314
+ assert_equal 1, left.priority_compare(right)
315
+ end
316
+
317
+ def assert_priority(left, middle, right)
318
+ assert_priority_less left, right
319
+ assert_priority_same left, middle
320
+ assert_priority_more right, left
321
+ end
322
+
323
+ let(:text_1) { mime_type("text/1") }
324
+ let(:text_1p) { mime_type("text/1") }
325
+ let(:text_2) { mime_type("text/2") }
326
+
327
+ it "sorts (1) based on the simplified type" do
328
+ assert_priority text_1, text_1p, text_2
329
+ end
330
+
331
+ it "sorts (2) based on extensions" do
332
+ text_1.extensions = ["foo", "bar"]
333
+ text_2.extensions = ["foo"]
334
+
335
+ assert_priority_same text_1, text_2
336
+
337
+ text_2.registered = true
338
+
339
+ assert_priority_more text_1, text_2
340
+ end
341
+
342
+ it "sorts (3) based on the registration state" do
343
+ text_1.registered = text_1p.registered = true
344
+ text_1b = mime_type(text_1) { |t| t.registered = false }
345
+
346
+ assert_priority text_1, text_1p, text_1b
347
+ end
348
+
349
+ it "sorts (4) based on the completeness" do
350
+ text_1.extensions = text_1p.extensions = "1"
351
+ text_1b = mime_type(text_1) { |t| t.extensions = nil }
352
+
353
+ assert_priority text_1, text_1p, text_1b
354
+ end
355
+
356
+ it "sorts (5) based on obsolete status" do
357
+ text_1.obsolete = text_1p.obsolete = false
358
+ text_1b = mime_type(text_1) { |t| t.obsolete = true }
359
+
360
+ assert_priority text_1, text_1p, text_1b
361
+ end
362
+
363
+ it "sorts (5) based on the use-instead value" do
364
+ text_1.obsolete = text_1p.obsolete = true
365
+ text_1.use_instead = text_1p.use_instead = "abc/xyz"
366
+ text_1b = mime_type(text_1) { |t| t.use_instead = nil }
367
+
368
+ assert_priority text_1, text_1p, text_1b
369
+
370
+ text_1b.use_instead = "abc/zzz"
371
+
372
+ assert_priority text_1, text_1p, text_1b
373
+ end
374
+ end
375
+
376
+ describe "#raw_media_type" do
377
+ it "extracts the media type as case-preserved" do
378
+ assert_equal "Text", mime_type("Text/plain").raw_media_type
379
+ end
380
+
381
+ it "does not remove x- prefixes" do
382
+ assert_equal("x-appl", x_appl_x_zip.raw_media_type)
383
+ end
384
+ end
385
+
386
+ describe "#media_type" do
387
+ it "extracts the media type as lowercase" do
388
+ assert_equal "text", text_plain.media_type
389
+ end
390
+
391
+ it "does not remove x- prefixes" do
392
+ assert_equal("x-appl", x_appl_x_zip.media_type)
393
+ end
394
+ end
395
+
396
+ describe "#raw_media_type" do
397
+ it "extracts the media type as case-preserved" do
398
+ assert_equal "Text", mime_type("Text/plain").raw_media_type
399
+ end
400
+
401
+ it "does not remove x- prefixes" do
402
+ assert_equal("x-appl", x_appl_x_zip.raw_media_type)
403
+ end
404
+ end
405
+
406
+ describe "#sub_type" do
407
+ it "extracts the sub type as lowercase" do
408
+ assert_equal "plain", text_plain.sub_type
409
+ end
410
+
411
+ it "does not remove x- prefixes" do
412
+ assert_equal("x-zip", x_appl_x_zip.sub_type)
413
+ end
414
+ end
415
+
416
+ describe "#raw_sub_type" do
417
+ it "extracts the sub type as case-preserved" do
418
+ assert_equal "Plain", mime_type("text/Plain").raw_sub_type
419
+ end
420
+
421
+ it "does not remove x- prefixes" do
422
+ assert_equal("x-zip", x_appl_x_zip.raw_sub_type)
423
+ end
424
+ end
425
+
426
+ describe "#to_h" do
427
+ let(:t) { mime_type("a/b") }
428
+
429
+ it "has the required keys (content-type, registered, encoding)" do
430
+ assert_has_keys t.to_h, %w[content-type registered encoding]
431
+ end
432
+
433
+ it "has the docs key if there are documents" do
434
+ assert_has_keys mime_type(t) { |v| v.docs = "a" }.to_h, %w[docs]
435
+ end
436
+
437
+ it "has the extensions key if set" do
438
+ assert_has_keys mime_type(t) { |v| v.extensions = "a" }.to_h,
439
+ "extensions"
440
+ end
441
+
442
+ it "has the preferred-extension key if set" do
443
+ assert_has_keys mime_type(t) { |v| v.preferred_extension = "a" }.to_h,
444
+ "preferred-extension"
445
+ end
446
+
447
+ it "has the obsolete key if set" do
448
+ assert_has_keys mime_type(t) { |v| v.obsolete = true }.to_h, "obsolete"
449
+ end
450
+
451
+ it "has the obsolete and use-instead keys if set" do
452
+ assert_has_keys mime_type(t) { |v|
453
+ v.obsolete = true
454
+ v.use_instead = "c/d"
455
+ }.to_h, %w[obsolete use-instead]
456
+ end
457
+
458
+ it "has the signature key if set" do
459
+ assert_has_keys mime_type(t) { |v| v.signature = true }.to_h, "signature"
460
+ end
461
+ end
462
+
463
+ describe "#to_json" do
464
+ let(:expected_1) {
465
+ '{"content-type":"a/b","encoding":"base64","registered":false}'
466
+ }
467
+ let(:expected_2) {
468
+ '{"content-type":"a/b","encoding":"base64","registered":true,"provisional":true}'
469
+ }
470
+
471
+ it "converts to JSON when requested" do
472
+ assert_equal expected_1, mime_type("a/b").to_json
473
+ end
474
+
475
+ it "converts to JSON with provisional when requested" do
476
+ type = mime_type("a/b") do |t|
477
+ t.registered = true
478
+ t.provisional = true
479
+ end
480
+ assert_equal expected_2, type.to_json
481
+ end
482
+ end
483
+
484
+ describe "#to_s, #to_str" do
485
+ it "represents itself as a string of the canonical content_type" do
486
+ assert_equal "text/plain", text_plain.to_s
487
+ end
488
+
489
+ it "acts like a string of the canonical content_type for comparison" do
490
+ assert_equal text_plain, "text/plain"
491
+ end
492
+
493
+ it "acts like a string for other purposes" do
494
+ assert_equal "stringy", "text/plain".sub(text_plain, "stringy")
495
+ end
496
+ end
497
+
498
+ describe "#xrefs, #xrefs=" do
499
+ let(:expected) {
500
+ MIME::Types::Container.new("rfc" => Set["rfc1234", "rfc5678"])
501
+ }
502
+
503
+ it "returns the expected results" do
504
+ application_javascript.xrefs = {
505
+ "rfc" => %w[rfc5678 rfc1234 rfc1234]
506
+ }
507
+
508
+ assert_equal expected, application_javascript.xrefs
509
+ end
510
+ end
511
+
512
+ describe "#xref_urls" do
513
+ let(:expected) {
514
+ [
515
+ "http://www.iana.org/go/draft1",
516
+ "http://www.iana.org/assignments/media-types/a/b",
517
+ "http://www.iana.org/assignments/media-types/media-types.xhtml#p-1",
518
+ "http://www.iana.org/go/rfc-1",
519
+ "http://www.rfc-editor.org/errata_search.php?eid=err-1",
520
+ "http://example.org",
521
+ "text"
522
+ ]
523
+ }
524
+
525
+ let(:type) {
526
+ mime_type("a/b").tap do |t|
527
+ t.xrefs = {
528
+ "draft" => ["RFC1"],
529
+ "template" => ["a/b"],
530
+ "person" => ["p-1"],
531
+ "rfc" => ["rfc-1"],
532
+ "rfc-errata" => ["err-1"],
533
+ "uri" => ["http://example.org"],
534
+ "text" => ["text"]
535
+ }
536
+ end
537
+ }
538
+
539
+ it "translates according to given rules" do
540
+ assert_equal expected, type.xref_urls
541
+ end
542
+ end
543
+
544
+ describe "#use_instead" do
545
+ it "is nil unless the type is obsolete" do
546
+ assert_nil text_plain.use_instead
547
+ end
548
+
549
+ it "is nil if not set and the type is obsolete" do
550
+ text_plain.obsolete = true
551
+ assert_nil text_plain.use_instead
552
+ end
553
+
554
+ it "is a different type if set and the type is obsolete" do
555
+ text_plain.obsolete = true
556
+ text_plain.use_instead = "text/html"
557
+ assert_equal "text/html", text_plain.use_instead
558
+ end
559
+ end
560
+
561
+ describe "#preferred_extension, #preferred_extension=" do
562
+ it "is nil when not set and there are no extensions" do
563
+ assert_nil text_plain.preferred_extension
564
+ end
565
+
566
+ it "is the first extension when not set but there are extensions" do
567
+ assert_equal "yaml", text_x_yaml.preferred_extension
568
+ end
569
+
570
+ it "is the extension provided when set" do
571
+ text_x_yaml.preferred_extension = "yml"
572
+ assert_equal "yml", text_x_yaml.preferred_extension
573
+ end
574
+
575
+ it "is adds the preferred extension if it does not exist" do
576
+ text_x_yaml.preferred_extension = "yz"
577
+ assert_equal "yz", text_x_yaml.preferred_extension
578
+ assert_includes text_x_yaml.extensions, "yz"
579
+ end
580
+ end
581
+
582
+ describe "#friendly" do
583
+ it "returns English by default" do
584
+ assert_equal "YAML Structured Document", text_x_yaml.friendly
585
+ end
586
+
587
+ it "returns English when requested" do
588
+ assert_equal "YAML Structured Document", text_x_yaml.friendly("en")
589
+ assert_equal "YAML Structured Document", text_x_yaml.friendly(:en)
590
+ end
591
+
592
+ it "returns nothing for an unknown language" do
593
+ assert_nil text_x_yaml.friendly("zz")
594
+ end
595
+
596
+ it "merges new values from an array parameter" do
597
+ expected = {"en" => "Text files"}
598
+ assert_equal expected, text_plain.friendly(["en", "Text files"])
599
+ expected.update("fr" => "des fichiers texte")
600
+ assert_equal expected,
601
+ text_plain.friendly(["fr", "des fichiers texte"])
602
+ end
603
+
604
+ it "merges new values from a hash parameter" do
605
+ expected = {"en" => "Text files"}
606
+ assert_equal expected, text_plain.friendly(expected)
607
+ french = {"fr" => "des fichiers texte"}
608
+ expected.update(french)
609
+ assert_equal expected, text_plain.friendly(french)
610
+ end
611
+
612
+ it "raises an ArgumentError if an unknown value is provided" do
613
+ exception = assert_raises ArgumentError do
614
+ text_plain.friendly(1)
615
+ end
616
+
617
+ assert_equal "Expected a language or translation set, not 1",
618
+ exception.message
619
+ end
620
+ end
621
+ end