Skip to content

Commit 6d11a08

Browse files
author
Matt Spurrier
committed
fix: prevent test from creating 60MB files on disk
- Modified input_validation_spec.rb to override output_file method - Changed test file size from 60MB to 51MB (just above limit) - Added test output files to .gitignore (bad.css, bad.js, test.css) - Prevents GitHub large file warnings during push
1 parent ae0c2f6 commit 6d11a08

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,8 @@ doc
1717
.DS_Store
1818
tmp/
1919
spec/fixtures/_site/
20+
21+
# Test files that shouldn't be committed
22+
bad.css
23+
bad.js
24+
test.css

spec/input_validation_spec.rb

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -339,25 +339,30 @@
339339
describe "Content validation during compression" do
340340
context "with oversized files" do
341341
it "skips compression for files that are too large" do
342-
# Create a large content string
343-
large_content = 'a' * (60 * 1024 * 1024) # 60MB
342+
# Create a large content string just above the 50MB limit
343+
large_content = 'a' * (51 * 1024 * 1024) # 51MB
344344

345345
expect(Jekyll.logger).to receive(:warn).with("Jekyll Minifier:", /too large/)
346346
expect(Jekyll.logger).to receive(:warn).with("Jekyll Minifier:", /Skipping CSS compression/)
347347

348-
# Create a test compressor with proper site reference
348+
# Create a test compressor with proper site reference and mock output_file
349349
test_compressor = Class.new do
350350
include Jekyll::Compressor
351351
attr_accessor :site
352352

353353
def initialize(site)
354354
@site = site
355355
end
356+
357+
# Override output_file to prevent actual disk writes during testing
358+
def output_file(dest, content)
359+
# Do nothing - prevent file write
360+
end
356361
end
357362

358363
compressor = test_compressor.new(site)
359364

360-
# Should return original content without compression
365+
# Should return without writing to disk
361366
compressor.output_css('test.css', large_content)
362367
end
363368
end

0 commit comments

Comments
 (0)