kt-paperclip 5.4.0 → 7.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (159) hide show
  1. checksums.yaml +4 -4
  2. data/.github/FUNDING.yml +3 -0
  3. data/.github/ISSUE_TEMPLATE/bug_report.md +38 -0
  4. data/.github/ISSUE_TEMPLATE/custom.md +10 -0
  5. data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
  6. data/.hound.yml +3 -1055
  7. data/.rubocop.yml +1061 -1
  8. data/.travis.yml +23 -4
  9. data/Appraisals +23 -0
  10. data/CONTRIBUTING.md +4 -5
  11. data/Gemfile +10 -7
  12. data/NEWS +52 -0
  13. data/README.md +58 -46
  14. data/Rakefile +29 -21
  15. data/UPGRADING +3 -3
  16. data/features/basic_integration.feature +4 -0
  17. data/features/migration.feature +10 -51
  18. data/features/step_definitions/attachment_steps.rb +23 -13
  19. data/features/step_definitions/html_steps.rb +5 -5
  20. data/features/step_definitions/rails_steps.rb +29 -9
  21. data/features/step_definitions/s3_steps.rb +3 -3
  22. data/features/step_definitions/web_steps.rb +5 -6
  23. data/features/support/env.rb +4 -4
  24. data/features/support/fakeweb.rb +3 -5
  25. data/features/support/file_helpers.rb +2 -2
  26. data/features/support/paths.rb +4 -4
  27. data/features/support/rails.rb +7 -7
  28. data/features/support/selectors.rb +1 -1
  29. data/gemfiles/4.2.gemfile +7 -4
  30. data/gemfiles/5.0.gemfile +7 -4
  31. data/gemfiles/5.1.gemfile +20 -0
  32. data/gemfiles/5.2.gemfile +20 -0
  33. data/gemfiles/6.0.gemfile +20 -0
  34. data/gemfiles/6.1.gemfile +21 -0
  35. data/gemfiles/7.0.gemfile +21 -0
  36. data/lib/generators/paperclip/paperclip_generator.rb +6 -8
  37. data/lib/paperclip/attachment.rb +103 -105
  38. data/lib/paperclip/attachment_registry.rb +2 -2
  39. data/lib/paperclip/content_type_detector.rb +10 -5
  40. data/lib/paperclip/file_command_content_type_detector.rb +1 -3
  41. data/lib/paperclip/filename_cleaner.rb +0 -1
  42. data/lib/paperclip/geometry.rb +18 -19
  43. data/lib/paperclip/geometry_detector_factory.rb +13 -16
  44. data/lib/paperclip/geometry_parser_factory.rb +5 -5
  45. data/lib/paperclip/glue.rb +3 -3
  46. data/lib/paperclip/has_attached_file.rb +5 -4
  47. data/lib/paperclip/helpers.rb +3 -3
  48. data/lib/paperclip/interpolations.rb +42 -38
  49. data/lib/paperclip/io_adapters/abstract_adapter.rb +16 -14
  50. data/lib/paperclip/io_adapters/attachment_adapter.rb +12 -6
  51. data/lib/paperclip/io_adapters/data_uri_adapter.rb +1 -1
  52. data/lib/paperclip/io_adapters/file_adapter.rb +1 -3
  53. data/lib/paperclip/io_adapters/http_url_proxy_adapter.rb +1 -1
  54. data/lib/paperclip/io_adapters/identity_adapter.rb +1 -2
  55. data/lib/paperclip/io_adapters/registry.rb +1 -1
  56. data/lib/paperclip/io_adapters/stringio_adapter.rb +1 -1
  57. data/lib/paperclip/io_adapters/uploaded_file_adapter.rb +6 -8
  58. data/lib/paperclip/io_adapters/uri_adapter.rb +21 -9
  59. data/lib/paperclip/logger.rb +1 -1
  60. data/lib/paperclip/matchers/have_attached_file_matcher.rb +4 -4
  61. data/lib/paperclip/matchers/validate_attachment_content_type_matcher.rb +19 -18
  62. data/lib/paperclip/matchers/validate_attachment_presence_matcher.rb +4 -4
  63. data/lib/paperclip/matchers/validate_attachment_size_matcher.rb +11 -10
  64. data/lib/paperclip/matchers.rb +4 -4
  65. data/lib/paperclip/media_type_spoof_detector.rb +13 -13
  66. data/lib/paperclip/missing_attachment_styles.rb +11 -6
  67. data/lib/paperclip/processor.rb +13 -6
  68. data/lib/paperclip/processor_helpers.rb +3 -1
  69. data/lib/paperclip/rails_environment.rb +1 -5
  70. data/lib/paperclip/railtie.rb +5 -5
  71. data/lib/paperclip/schema.rb +16 -12
  72. data/lib/paperclip/storage/filesystem.rb +6 -8
  73. data/lib/paperclip/storage/fog.rb +36 -32
  74. data/lib/paperclip/storage/s3.rb +68 -76
  75. data/lib/paperclip/style.rb +3 -6
  76. data/lib/paperclip/tempfile.rb +4 -5
  77. data/lib/paperclip/tempfile_factory.rb +0 -1
  78. data/lib/paperclip/thumbnail.rb +11 -11
  79. data/lib/paperclip/url_generator.rb +5 -5
  80. data/lib/paperclip/validators/attachment_content_type_validator.rb +11 -4
  81. data/lib/paperclip/validators/attachment_file_name_validator.rb +14 -12
  82. data/lib/paperclip/validators/attachment_file_type_ignorance_validator.rb +1 -2
  83. data/lib/paperclip/validators/attachment_presence_validator.rb +3 -5
  84. data/lib/paperclip/validators/attachment_size_validator.rb +28 -11
  85. data/lib/paperclip/validators/media_type_spoof_detection_validator.rb +3 -1
  86. data/lib/paperclip/validators.rb +16 -17
  87. data/lib/paperclip/version.rb +1 -3
  88. data/lib/paperclip.rb +49 -48
  89. data/lib/tasks/paperclip.rake +23 -24
  90. data/paperclip.gemspec +29 -33
  91. data/shoulda_macros/paperclip.rb +16 -16
  92. data/spec/paperclip/attachment_definitions_spec.rb +5 -5
  93. data/spec/paperclip/attachment_processing_spec.rb +22 -23
  94. data/spec/paperclip/attachment_registry_spec.rb +15 -15
  95. data/spec/paperclip/attachment_spec.rb +238 -196
  96. data/spec/paperclip/content_type_detector_spec.rb +18 -12
  97. data/spec/paperclip/file_command_content_type_detector_spec.rb +10 -10
  98. data/spec/paperclip/filename_cleaner_spec.rb +3 -4
  99. data/spec/paperclip/geometry_detector_spec.rb +7 -8
  100. data/spec/paperclip/geometry_parser_spec.rb +31 -31
  101. data/spec/paperclip/geometry_spec.rb +24 -24
  102. data/spec/paperclip/glue_spec.rb +3 -5
  103. data/spec/paperclip/has_attached_file_spec.rb +46 -126
  104. data/spec/paperclip/integration_spec.rb +111 -77
  105. data/spec/paperclip/interpolations_spec.rb +101 -93
  106. data/spec/paperclip/io_adapters/abstract_adapter_spec.rb +41 -13
  107. data/spec/paperclip/io_adapters/attachment_adapter_spec.rb +8 -10
  108. data/spec/paperclip/io_adapters/data_uri_adapter_spec.rb +13 -14
  109. data/spec/paperclip/io_adapters/empty_string_adapter_spec.rb +4 -4
  110. data/spec/paperclip/io_adapters/file_adapter_spec.rb +12 -12
  111. data/spec/paperclip/io_adapters/http_url_proxy_adapter_spec.rb +58 -37
  112. data/spec/paperclip/io_adapters/identity_adapter_spec.rb +1 -1
  113. data/spec/paperclip/io_adapters/nil_adapter_spec.rb +2 -2
  114. data/spec/paperclip/io_adapters/registry_spec.rb +4 -4
  115. data/spec/paperclip/io_adapters/stringio_adapter_spec.rb +10 -10
  116. data/spec/paperclip/io_adapters/uploaded_file_adapter_spec.rb +6 -6
  117. data/spec/paperclip/io_adapters/uri_adapter_spec.rb +90 -31
  118. data/spec/paperclip/matchers/have_attached_file_matcher_spec.rb +3 -3
  119. data/spec/paperclip/matchers/validate_attachment_content_type_matcher_spec.rb +4 -5
  120. data/spec/paperclip/matchers/validate_attachment_presence_matcher_spec.rb +4 -4
  121. data/spec/paperclip/matchers/validate_attachment_size_matcher_spec.rb +4 -4
  122. data/spec/paperclip/media_type_spoof_detector_spec.rb +50 -24
  123. data/spec/paperclip/meta_class_spec.rb +3 -3
  124. data/spec/paperclip/paperclip_missing_attachment_styles_spec.rb +28 -24
  125. data/spec/paperclip/paperclip_spec.rb +15 -11
  126. data/spec/paperclip/plural_cache_spec.rb +8 -8
  127. data/spec/paperclip/processor_helpers_spec.rb +35 -35
  128. data/spec/paperclip/processor_spec.rb +8 -8
  129. data/spec/paperclip/rails_environment_spec.rb +7 -10
  130. data/spec/paperclip/rake_spec.rb +39 -39
  131. data/spec/paperclip/schema_spec.rb +57 -53
  132. data/spec/paperclip/storage/filesystem_spec.rb +29 -6
  133. data/spec/paperclip/storage/fog_spec.rb +122 -82
  134. data/spec/paperclip/storage/s3_live_spec.rb +22 -22
  135. data/spec/paperclip/storage/s3_spec.rb +649 -583
  136. data/spec/paperclip/style_spec.rb +67 -71
  137. data/spec/paperclip/tempfile_factory_spec.rb +5 -5
  138. data/spec/paperclip/thumbnail_spec.rb +68 -67
  139. data/spec/paperclip/url_generator_spec.rb +18 -19
  140. data/spec/paperclip/validators/attachment_content_type_validator_spec.rb +115 -27
  141. data/spec/paperclip/validators/attachment_file_name_validator_spec.rb +105 -16
  142. data/spec/paperclip/validators/attachment_presence_validator_spec.rb +5 -5
  143. data/spec/paperclip/validators/attachment_size_validator_spec.rb +111 -21
  144. data/spec/paperclip/validators/media_type_spoof_detection_validator_spec.rb +9 -13
  145. data/spec/paperclip/validators_spec.rb +61 -46
  146. data/spec/spec_helper.rb +21 -23
  147. data/spec/support/assertions.rb +8 -6
  148. data/spec/support/fake_model.rb +1 -2
  149. data/spec/support/fake_rails.rb +1 -1
  150. data/spec/support/fixtures/aws_s3.yml +13 -0
  151. data/spec/support/fixtures/sample.xlsm +0 -0
  152. data/spec/support/matchers/exist.rb +1 -1
  153. data/spec/support/matchers/have_column.rb +1 -1
  154. data/spec/support/mock_url_generator_builder.rb +2 -3
  155. data/spec/support/model_reconstruction.rb +16 -12
  156. data/spec/support/reporting.rb +1 -1
  157. data/spec/support/test_data.rb +2 -2
  158. metadata +58 -106
  159. data/spec/support/conditional_filter_helper.rb +0 -5
@@ -1,11 +1,10 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
1
+ require "spec_helper"
3
2
 
4
3
  describe Paperclip::Style do
5
4
  context "A style rule" do
6
5
  before do
7
6
  @attachment = attachment path: ":basename.:extension",
8
- styles: { foo: {geometry: "100x100#", format: :png} },
7
+ styles: { foo: { geometry: "100x100#", format: :png } },
9
8
  whiny: true
10
9
  @style = @attachment.styles[:foo]
11
10
  end
@@ -40,13 +39,13 @@ describe Paperclip::Style do
40
39
  before do
41
40
  @attachment = attachment path: ":basename.:extension",
42
41
  whiny_thumbnails: true,
43
- processors: lambda {|a| [:test]},
42
+ processors: lambda { |_a| [:test] },
44
43
  styles: {
45
- foo: lambda{|a| "300x300#"},
44
+ foo: lambda { |_a| "300x300#" },
46
45
  bar: {
47
- geometry: lambda{|a| "300x300#"},
48
- convert_options: lambda{|a| "-do_stuff"},
49
- source_file_options: lambda{|a| "-do_extra_stuff"}
46
+ geometry: lambda { |_a| "300x300#" },
47
+ convert_options: lambda { |_a| "-do_stuff" },
48
+ source_file_options: lambda { |_a| "-do_extra_stuff" }
50
49
  }
51
50
  }
52
51
  end
@@ -65,7 +64,7 @@ describe Paperclip::Style do
65
64
  before do
66
65
  styles = {}
67
66
  styles[:aslist] = ["100x100", :png]
68
- styles[:ashash] = {geometry: "100x100", format: :png}
67
+ styles[:ashash] = { geometry: "100x100", format: :png }
69
68
  styles[:asstring] = "100x100"
70
69
  @attachment = attachment path: ":basename.:extension",
71
70
  styles: styles
@@ -102,21 +101,21 @@ describe Paperclip::Style do
102
101
  context "An attachment with :convert_options" do
103
102
  it "does not have called extra_options_for(:thumb/:large) on initialization" do
104
103
  @attachment = attachment path: ":basename.:extension",
105
- styles: {thumb: "100x100", large: "400x400"},
106
- convert_options: {all: "-do_stuff", thumb: "-thumbnailize"}
107
- @attachment.expects(:extra_options_for).never
104
+ styles: { thumb: "100x100", large: "400x400" },
105
+ convert_options: { all: "-do_stuff", thumb: "-thumbnailize" }
106
+ expect(@attachment).to_not receive(:extra_options_for)
108
107
  @style = @attachment.styles[:thumb]
109
108
  end
110
109
 
111
110
  it "calls extra_options_for(:thumb/:large) when convert options are requested" do
112
111
  @attachment = attachment path: ":basename.:extension",
113
- styles: {thumb: "100x100", large: "400x400"},
114
- convert_options: {all: "-do_stuff", thumb: "-thumbnailize"}
112
+ styles: { thumb: "100x100", large: "400x400" },
113
+ convert_options: { all: "-do_stuff", thumb: "-thumbnailize" }
115
114
  @style = @attachment.styles[:thumb]
116
115
  @file = StringIO.new("...")
117
- @file.stubs(:original_filename).returns("file.jpg")
116
+ allow(@file).to receive(:original_filename).and_return("file.jpg")
118
117
 
119
- @attachment.expects(:extra_options_for).with(:thumb)
118
+ expect(@attachment).to receive(:extra_options_for).with(:thumb)
120
119
  @attachment.styles[:thumb].convert_options
121
120
  end
122
121
  end
@@ -124,21 +123,21 @@ describe Paperclip::Style do
124
123
  context "An attachment with :source_file_options" do
125
124
  it "does not have called extra_source_file_options_for(:thumb/:large) on initialization" do
126
125
  @attachment = attachment path: ":basename.:extension",
127
- styles: {thumb: "100x100", large: "400x400"},
128
- source_file_options: {all: "-density 400", thumb: "-depth 8"}
129
- @attachment.expects(:extra_source_file_options_for).never
126
+ styles: { thumb: "100x100", large: "400x400" },
127
+ source_file_options: { all: "-density 400", thumb: "-depth 8" }
128
+ expect(@attachment).to_not receive(:extra_source_file_options_for)
130
129
  @style = @attachment.styles[:thumb]
131
130
  end
132
131
 
133
132
  it "calls extra_options_for(:thumb/:large) when convert options are requested" do
134
133
  @attachment = attachment path: ":basename.:extension",
135
- styles: {thumb: "100x100", large: "400x400"},
136
- source_file_options: {all: "-density 400", thumb: "-depth 8"}
134
+ styles: { thumb: "100x100", large: "400x400" },
135
+ source_file_options: { all: "-density 400", thumb: "-depth 8" }
137
136
  @style = @attachment.styles[:thumb]
138
137
  @file = StringIO.new("...")
139
- @file.stubs(:original_filename).returns("file.jpg")
138
+ allow(@file).to receive(:original_filename).and_return("file.jpg")
140
139
 
141
- @attachment.expects(:extra_source_file_options_for).with(:thumb)
140
+ expect(@attachment).to receive(:extra_source_file_options_for).with(:thumb)
142
141
  @attachment.styles[:thumb].source_file_options
143
142
  end
144
143
  end
@@ -151,21 +150,20 @@ describe Paperclip::Style do
151
150
  geometry: "100x100#",
152
151
  format: :png,
153
152
  processors: [:test]
154
- }
155
- },
153
+ }
154
+ },
156
155
  processors: [:thumbnail]
157
156
  @style = @attachment.styles[:foo]
158
157
  end
159
158
 
160
159
  it "does not get processors from the attachment" do
161
- @attachment.expects(:processors).never
160
+ expect(@attachment).to_not receive(:processors)
162
161
  assert_not_equal [:thumbnail], @style.processors
163
162
  end
164
163
 
165
164
  it "reports its own processors" do
166
165
  assert_equal [:test], @style.processors
167
166
  end
168
-
169
167
  end
170
168
 
171
169
  context "A style rule with :processors supplied as procs" do
@@ -175,9 +173,9 @@ describe Paperclip::Style do
175
173
  foo: {
176
174
  geometry: "100x100#",
177
175
  format: :png,
178
- processors: lambda{|a| [:test]}
179
- }
180
- },
176
+ processors: lambda { |_a| [:test] }
177
+ }
178
+ },
181
179
  processors: [:thumbnail]
182
180
  end
183
181
 
@@ -195,13 +193,12 @@ describe Paperclip::Style do
195
193
  @attachment = attachment path: ":basename.:extension",
196
194
  styles: {
197
195
  thumb: "100x100",
198
- large: {geometry: "400x400",
199
- convert_options: "-do_stuff",
200
- source_file_options: "-do_extra_stuff"
201
- }
196
+ large: { geometry: "400x400",
197
+ convert_options: "-do_stuff",
198
+ source_file_options: "-do_extra_stuff" }
202
199
  }
203
200
  @file = StringIO.new("...")
204
- @file.stubs(:original_filename).returns("file.jpg")
201
+ allow(@file).to receive(:original_filename).and_return("file.jpg")
205
202
  end
206
203
 
207
204
  it "has empty options for :thumb style" do
@@ -216,40 +213,39 @@ describe Paperclip::Style do
216
213
  end
217
214
 
218
215
  context "A style rule supplied with default format" do
219
- before do
220
- @attachment = attachment default_format: :png,
221
- styles: {
222
- asstring: "300x300#",
223
- aslist: ["300x300#", :jpg],
224
- ashash: {
225
- geometry: "300x300#",
226
- convert_options: "-do_stuff"
227
- }
228
- }
229
- end
230
-
231
- it "has the right number of styles" do
232
- expect(@attachment.styles).to be_a Hash
233
- assert_equal 3, @attachment.styles.size
234
- end
235
-
236
- it "has styles as Style objects" do
237
- [:aslist, :ashash, :aslist].each do |s|
238
- expect(@attachment.styles[s]).to be_a Paperclip::Style
239
- end
240
- end
241
-
242
- it "has the right geometries" do
243
- [:aslist, :ashash, :aslist].each do |s|
244
- assert_equal @attachment.styles[s].geometry, "300x300#"
245
- end
246
- end
247
-
248
- it "has the right formats" do
249
- assert_equal @attachment.styles[:aslist].format, :jpg
250
- assert_equal @attachment.styles[:ashash].format, :png
251
- assert_equal @attachment.styles[:asstring].format, :png
252
- end
253
-
254
- end
216
+ before do
217
+ @attachment = attachment default_format: :png,
218
+ styles: {
219
+ asstring: "300x300#",
220
+ aslist: ["300x300#", :jpg],
221
+ ashash: {
222
+ geometry: "300x300#",
223
+ convert_options: "-do_stuff"
224
+ }
225
+ }
226
+ end
227
+
228
+ it "has the right number of styles" do
229
+ expect(@attachment.styles).to be_a Hash
230
+ assert_equal 3, @attachment.styles.size
231
+ end
232
+
233
+ it "has styles as Style objects" do
234
+ [:aslist, :ashash, :aslist].each do |s|
235
+ expect(@attachment.styles[s]).to be_a Paperclip::Style
236
+ end
237
+ end
238
+
239
+ it "has the right geometries" do
240
+ [:aslist, :ashash, :aslist].each do |s|
241
+ assert_equal @attachment.styles[s].geometry, "300x300#"
242
+ end
243
+ end
244
+
245
+ it "has the right formats" do
246
+ assert_equal @attachment.styles[:aslist].format, :jpg
247
+ assert_equal @attachment.styles[:ashash].format, :png
248
+ assert_equal @attachment.styles[:asstring].format, :png
249
+ end
250
+ end
255
251
  end
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe Paperclip::TempfileFactory do
4
4
  it "is able to generate a tempfile with the right name" do
@@ -17,14 +17,14 @@ describe Paperclip::TempfileFactory do
17
17
  end
18
18
 
19
19
  it "is able to generate a tempfile from a file with a really long name" do
20
- filename = "#{"longfilename" * 100}.png"
20
+ filename = "#{'longfilename' * 100}.png"
21
21
  file = subject.generate(filename)
22
22
  assert File.extname(file.path), "png"
23
23
  end
24
24
 
25
- it 'is able to take nothing as a parameter and not error' do
26
- file = subject.generate
27
- assert File.exist?(file.path)
25
+ it "is able to take nothing as a parameter and not error" do
26
+ file = subject.generate
27
+ assert File.exist?(file.path)
28
28
  end
29
29
 
30
30
  it "does not throw Errno::ENAMETOOLONG when it has a really long name" do
@@ -1,9 +1,9 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe Paperclip::Thumbnail do
4
4
  context "An image" do
5
5
  before do
6
- @file = File.new(fixture_file("5k.png"), 'rb')
6
+ @file = File.new(fixture_file("5k.png"), "rb")
7
7
  end
8
8
 
9
9
  after { @file.close }
@@ -11,15 +11,14 @@ describe Paperclip::Thumbnail do
11
11
  [["600x600>", "434x66"],
12
12
  ["400x400>", "400x61"],
13
13
  ["32x32<", "434x66"],
14
- [nil, "434x66"]
15
- ].each do |args|
14
+ [nil, "434x66"]].each do |args|
16
15
  context "being thumbnailed with a geometry of #{args[0]}" do
17
16
  before do
18
17
  @thumb = Paperclip::Thumbnail.new(@file, geometry: args[0])
19
18
  end
20
19
 
21
20
  it "starts with dimensions of 434x66" do
22
- cmd = %Q[identify -format "%wx%h" "#{@file.path}"]
21
+ cmd = %[identify -format "%wx%h" "#{@file.path}"]
23
22
  assert_equal "434x66", `#{cmd}`.chomp
24
23
  end
25
24
 
@@ -33,7 +32,7 @@ describe Paperclip::Thumbnail do
33
32
  end
34
33
 
35
34
  it "is the size we expect it to be" do
36
- cmd = %Q[identify -format "%wx%h" "#{@thumb_result.path}"]
35
+ cmd = %[identify -format "%wx%h" "#{@thumb_result.path}"]
37
36
  assert_equal args[1], `#{cmd}`.chomp
38
37
  end
39
38
  end
@@ -46,18 +45,18 @@ describe Paperclip::Thumbnail do
46
45
  end
47
46
 
48
47
  it "lets us know when a command isn't found versus a processing error" do
49
- old_path = ENV['PATH']
48
+ old_path = ENV["PATH"]
50
49
  begin
51
- Terrapin::CommandLine.path = ''
52
- Paperclip.options[:command_path] = ''
53
- ENV['PATH'] = ''
50
+ Terrapin::CommandLine.path = ""
51
+ Paperclip.options[:command_path] = ""
52
+ ENV["PATH"] = ""
54
53
  assert_raises(Paperclip::Errors::CommandNotFoundError) do
55
54
  silence_stream(STDERR) do
56
55
  @thumb.make
57
56
  end
58
57
  end
59
58
  ensure
60
- ENV['PATH'] = old_path
59
+ ENV["PATH"] = old_path
61
60
  end
62
61
  end
63
62
 
@@ -83,9 +82,9 @@ describe Paperclip::Thumbnail do
83
82
  end
84
83
 
85
84
  it "sends the right command to convert when sent #make" do
86
- @thumb.expects(:convert).with do |*arg|
85
+ expect(@thumb).to receive(:convert) do |*arg|
87
86
  arg[0] == ':source -auto-orient -resize "x50" -crop "100x50+114+0" +repage :dest' &&
88
- arg[1][:source] == "#{File.expand_path(@thumb.file.path)}[0]"
87
+ arg[1][:source] == "#{File.expand_path(@thumb.file.path)}[0]"
89
88
  end
90
89
  @thumb.make
91
90
  end
@@ -96,8 +95,8 @@ describe Paperclip::Thumbnail do
96
95
  end
97
96
  end
98
97
 
99
- it 'crops a EXIF-rotated image properly' do
100
- file = File.new(fixture_file('rotated.jpg'))
98
+ it "crops a EXIF-rotated image properly" do
99
+ file = File.new(fixture_file("rotated.jpg"))
101
100
  thumb = Paperclip::Thumbnail.new(file, geometry: "50x50#")
102
101
 
103
102
  output_file = thumb.make
@@ -118,9 +117,9 @@ describe Paperclip::Thumbnail do
118
117
  end
119
118
 
120
119
  it "sends the right command to convert when sent #make" do
121
- @thumb.expects(:convert).with do |*arg|
120
+ expect(@thumb).to receive(:convert) do |*arg|
122
121
  arg[0] == '-strip :source -auto-orient -resize "x50" -crop "100x50+114+0" +repage :dest' &&
123
- arg[1][:source] == "#{File.expand_path(@thumb.file.path)}[0]"
122
+ arg[1][:source] == "#{File.expand_path(@thumb.file.path)}[0]"
124
123
  end
125
124
  @thumb.make
126
125
  end
@@ -159,9 +158,9 @@ describe Paperclip::Thumbnail do
159
158
  end
160
159
 
161
160
  it "sends the right command to convert when sent #make" do
162
- @thumb.expects(:convert).with do |*arg|
161
+ expect(@thumb).to receive(:convert) do |*arg|
163
162
  arg[0] == ':source -auto-orient -resize "x50" -crop "100x50+114+0" +repage -strip -depth 8 :dest' &&
164
- arg[1][:source] == "#{File.expand_path(@thumb.file.path)}[0]"
163
+ arg[1][:source] == "#{File.expand_path(@thumb.file.path)}[0]"
165
164
  end
166
165
  @thumb.make
167
166
  end
@@ -179,26 +178,28 @@ describe Paperclip::Thumbnail do
179
178
  end
180
179
 
181
180
  it "errors when trying to create the thumbnail" do
182
- assert_raises(Paperclip::Error) do
183
- silence_stream(STDERR) do
181
+ silence_stream(STDERR) do
182
+ expect do
184
183
  @thumb.make
185
- end
184
+ end.to raise_error(
185
+ Paperclip::Error, /unrecognized option `-this-aint-no-option'/
186
+ )
186
187
  end
187
188
  end
188
189
 
189
190
  it "lets us know when a command isn't found versus a processing error" do
190
- old_path = ENV['PATH']
191
+ old_path = ENV["PATH"]
191
192
  begin
192
- Terrapin::CommandLine.path = ''
193
- Paperclip.options[:command_path] = ''
194
- ENV['PATH'] = ''
193
+ Terrapin::CommandLine.path = ""
194
+ Paperclip.options[:command_path] = ""
195
+ ENV["PATH"] = ""
195
196
  assert_raises(Paperclip::Errors::CommandNotFoundError) do
196
197
  silence_stream(STDERR) do
197
198
  @thumb.make
198
199
  end
199
200
  end
200
201
  ensure
201
- ENV['PATH'] = old_path
202
+ ENV["PATH"] = old_path
202
203
  end
203
204
  end
204
205
  end
@@ -219,9 +220,9 @@ describe Paperclip::Thumbnail do
219
220
  context "being thumbnailed with default animated option (true)" do
220
221
  it "calls identify to check for animated images when sent #make" do
221
222
  thumb = Paperclip::Thumbnail.new(@file, geometry: "100x50#")
222
- thumb.expects(:identify).at_least_once.with do |*arg|
223
- arg[0] == '-format %m :file' &&
224
- arg[1][:file] == "#{File.expand_path(thumb.file.path)}[0]"
223
+ expect(thumb).to receive(:identify).at_least(1).times do |*arg|
224
+ arg[0] == "-format %m :file" &&
225
+ arg[1][:file] == "#{File.expand_path(thumb.file.path)}[0]"
225
226
  end
226
227
  thumb.make
227
228
  end
@@ -234,27 +235,27 @@ describe Paperclip::Thumbnail do
234
235
 
235
236
  it "produces the appropriate transformation_command" do
236
237
  GeoParser = Class.new do
237
- def self.from_file(file)
238
+ def self.from_file(_file)
238
239
  new
239
240
  end
240
241
 
241
- def transformation_to(target, should_crop)
242
+ def transformation_to(_target, _should_crop)
242
243
  ["SCALE", "CROP"]
243
244
  end
244
245
  end
245
246
 
246
- thumb = Paperclip::Thumbnail.new(@file, geometry: '50x50', file_geometry_parser: ::GeoParser)
247
+ thumb = Paperclip::Thumbnail.new(@file, geometry: "50x50", file_geometry_parser: ::GeoParser)
247
248
 
248
249
  transformation_command = thumb.transformation_command
249
250
 
250
- assert transformation_command.include?('-crop'),
251
- %{expected #{transformation_command.inspect} to include '-crop'}
251
+ assert transformation_command.include?("-crop"),
252
+ %{expected #{transformation_command.inspect} to include '-crop'}
252
253
  assert transformation_command.include?('"CROP"'),
253
- %{expected #{transformation_command.inspect} to include '"CROP"'}
254
- assert transformation_command.include?('-resize'),
255
- %{expected #{transformation_command.inspect} to include '-resize'}
254
+ %{expected #{transformation_command.inspect} to include '"CROP"'}
255
+ assert transformation_command.include?("-resize"),
256
+ %{expected #{transformation_command.inspect} to include '-resize'}
256
257
  assert transformation_command.include?('"SCALE"'),
257
- %{expected #{transformation_command.inspect} to include '"SCALE"'}
258
+ %{expected #{transformation_command.inspect} to include '"SCALE"'}
258
259
  end
259
260
  end
260
261
 
@@ -265,7 +266,7 @@ describe Paperclip::Thumbnail do
265
266
 
266
267
  it "produces the appropriate transformation_command" do
267
268
  GeoParser = Class.new do
268
- def self.parse(s)
269
+ def self.parse(_s)
269
270
  new
270
271
  end
271
272
 
@@ -274,26 +275,26 @@ describe Paperclip::Thumbnail do
274
275
  end
275
276
  end
276
277
 
277
- thumb = Paperclip::Thumbnail.new(@file, geometry: '50x50', string_geometry_parser: ::GeoParser)
278
+ thumb = Paperclip::Thumbnail.new(@file, geometry: "50x50", string_geometry_parser: ::GeoParser)
278
279
 
279
280
  transformation_command = thumb.transformation_command
280
281
 
281
282
  assert transformation_command.include?('"151x167"'),
282
- %{expected #{transformation_command.inspect} to include '151x167'}
283
+ %{expected #{transformation_command.inspect} to include '151x167'}
283
284
  end
284
285
  end
285
286
  end
286
287
 
287
288
  context "A multipage PDF" do
288
289
  before do
289
- @file = File.new(fixture_file("twopage.pdf"), 'rb')
290
+ @file = File.new(fixture_file("twopage.pdf"), "rb")
290
291
  end
291
292
 
292
293
  after { @file.close }
293
294
 
294
295
  it "starts with two pages with dimensions 612x792" do
295
- cmd = %Q[identify -format "%wx%h" "#{@file.path}"]
296
- assert_equal "612x792"*2, `#{cmd}`.chomp
296
+ cmd = %[identify -format "%wx%h" "#{@file.path}"]
297
+ assert_equal "612x792" * 2, `#{cmd}`.chomp
297
298
  end
298
299
 
299
300
  context "being thumbnailed at 100x100 with cropping" do
@@ -319,37 +320,37 @@ describe Paperclip::Thumbnail do
319
320
 
320
321
  context "An animated gif" do
321
322
  before do
322
- @file = File.new(fixture_file("animated.gif"), 'rb')
323
+ @file = File.new(fixture_file("animated.gif"), "rb")
323
324
  end
324
325
 
325
326
  after { @file.close }
326
327
 
327
328
  it "starts with 12 frames with size 100x100" do
328
- cmd = %Q[identify -format "%wx%h" "#{@file.path}"]
329
- assert_equal "100x100"*12, `#{cmd}`.chomp
329
+ cmd = %[identify -format "%wx%h" "#{@file.path}"]
330
+ assert_equal "100x100" * 12, `#{cmd}`.chomp
330
331
  end
331
332
 
332
333
  context "with static output" do
333
334
  before do
334
- @thumb = Paperclip::Thumbnail.new(@file, geometry: "50x50", format: :jpg)
335
+ @thumb = Paperclip::Thumbnail.new(@file, geometry: "50x50", format: :jpg)
335
336
  end
336
337
 
337
338
  it "creates the single frame thumbnail when sent #make" do
338
339
  dst = @thumb.make
339
- cmd = %Q[identify -format "%wx%h" "#{dst.path}"]
340
+ cmd = %[identify -format "%wx%h" "#{dst.path}"]
340
341
  assert_equal "50x50", `#{cmd}`.chomp
341
342
  end
342
343
  end
343
344
 
344
345
  context "with animated output format" do
345
346
  before do
346
- @thumb = Paperclip::Thumbnail.new(@file, geometry: "50x50", format: :gif)
347
+ @thumb = Paperclip::Thumbnail.new(@file, geometry: "50x50", format: :gif)
347
348
  end
348
349
 
349
350
  it "creates the 12 frames thumbnail when sent #make" do
350
351
  dst = @thumb.make
351
- cmd = %Q[identify -format "%wx%h," "#{dst.path}"]
352
- frames = `#{cmd}`.chomp.split(',')
352
+ cmd = %[identify -format "%wx%h," "#{dst.path}"]
353
+ frames = `#{cmd}`.chomp.split(",")
353
354
  assert_equal 12, frames.size
354
355
  assert_frame_dimensions (45..50), frames
355
356
  end
@@ -365,13 +366,13 @@ describe Paperclip::Thumbnail do
365
366
 
366
367
  context "with omitted output format" do
367
368
  before do
368
- @thumb = Paperclip::Thumbnail.new(@file, geometry: "50x50")
369
+ @thumb = Paperclip::Thumbnail.new(@file, geometry: "50x50")
369
370
  end
370
371
 
371
372
  it "creates the 12 frames thumbnail when sent #make" do
372
373
  dst = @thumb.make
373
- cmd = %Q[identify -format "%wx%h," "#{dst.path}"]
374
- frames = `#{cmd}`.chomp.split(',')
374
+ cmd = %[identify -format "%wx%h," "#{dst.path}"]
375
+ frames = `#{cmd}`.chomp.split(",")
375
376
  assert_equal 12, frames.size
376
377
  assert_frame_dimensions (45..50), frames
377
378
  end
@@ -387,14 +388,14 @@ describe Paperclip::Thumbnail do
387
388
 
388
389
  context "with unidentified source format" do
389
390
  before do
390
- @unidentified_file = File.new(fixture_file("animated.unknown"), 'rb')
391
+ @unidentified_file = File.new(fixture_file("animated.unknown"), "rb")
391
392
  @thumb = Paperclip::Thumbnail.new(@file, geometry: "60x60")
392
393
  end
393
394
 
394
395
  it "creates the 12 frames thumbnail when sent #make" do
395
396
  dst = @thumb.make
396
- cmd = %Q[identify -format "%wx%h," "#{dst.path}"]
397
- frames = `#{cmd}`.chomp.split(',')
397
+ cmd = %[identify -format "%wx%h," "#{dst.path}"]
398
+ frames = `#{cmd}`.chomp.split(",")
398
399
  assert_equal 12, frames.size
399
400
  assert_frame_dimensions (55..60), frames
400
401
  end
@@ -410,14 +411,14 @@ describe Paperclip::Thumbnail do
410
411
 
411
412
  context "with no source format" do
412
413
  before do
413
- @unidentified_file = File.new(fixture_file("animated"), 'rb')
414
+ @unidentified_file = File.new(fixture_file("animated"), "rb")
414
415
  @thumb = Paperclip::Thumbnail.new(@file, geometry: "70x70")
415
416
  end
416
417
 
417
418
  it "creates the 12 frames thumbnail when sent #make" do
418
419
  dst = @thumb.make
419
- cmd = %Q[identify -format "%wx%h," "#{dst.path}"]
420
- frames = `#{cmd}`.chomp.split(',')
420
+ cmd = %[identify -format "%wx%h," "#{dst.path}"]
421
+ frames = `#{cmd}`.chomp.split(",")
421
422
  assert_equal 12, frames.size
422
423
  assert_frame_dimensions (60..70), frames
423
424
  end
@@ -433,18 +434,18 @@ describe Paperclip::Thumbnail do
433
434
 
434
435
  context "with animated option set to false" do
435
436
  before do
436
- @thumb = Paperclip::Thumbnail.new(@file, geometry: "50x50", animated: false)
437
+ @thumb = Paperclip::Thumbnail.new(@file, geometry: "50x50", animated: false)
437
438
  end
438
439
 
439
440
  it "outputs the gif format" do
440
441
  dst = @thumb.make
441
- cmd = %Q[identify "#{dst.path}"]
442
+ cmd = %[identify "#{dst.path}"]
442
443
  assert_match /GIF/, `#{cmd}`.chomp
443
444
  end
444
445
 
445
446
  it "creates the single frame thumbnail when sent #make" do
446
447
  dst = @thumb.make
447
- cmd = %Q[identify -format "%wx%h" "#{dst.path}"]
448
+ cmd = %[identify -format "%wx%h" "#{dst.path}"]
448
449
  assert_equal "50x50", `#{cmd}`.chomp
449
450
  end
450
451
  end
@@ -455,7 +456,7 @@ describe Paperclip::Thumbnail do
455
456
  @file,
456
457
  geometry: "50x50",
457
458
  frame_index: 5,
458
- format: :jpg,
459
+ format: :jpg
459
460
  )
460
461
  end
461
462
 
@@ -471,7 +472,7 @@ describe Paperclip::Thumbnail do
471
472
  @file,
472
473
  geometry: "50x50",
473
474
  frame_index: 20,
474
- format: :jpg,
475
+ format: :jpg
475
476
  )
476
477
  end
477
478