Skip to content

Commit 0aaeb06

Browse files
committed
Fix File.exists? to File.exist? for compatibility with Ruby 3.2
1 parent d73dad7 commit 0aaeb06

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

app/controllers/docs_controller.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ def show
3232
if @meta_image.end_with? '.webp'
3333
# .webp -> .jpg
3434
# .webp -> .png
35-
@meta_image.gsub!('.webp', '.jpg') if File.exists? "public/#{@meta_image[0..-6]}.jpg"
36-
@meta_image.gsub!('.webp', '.jpeg') if File.exists? "public/#{@meta_image[0..-6]}.jpeg"
37-
@meta_image.gsub!('.webp', '.png') if File.exists? "public/#{@meta_image[0..-6]}.png"
35+
@meta_image.gsub!('.webp', '.jpg') if File.exist? "public/#{@meta_image[0..-6]}.jpg"
36+
@meta_image.gsub!('.webp', '.jpeg') if File.exist? "public/#{@meta_image[0..-6]}.jpeg"
37+
@meta_image.gsub!('.webp', '.png') if File.exist? "public/#{@meta_image[0..-6]}.png"
3838
end
3939

4040
# Add here if you want to optimize meta description.

app/models/podcast.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def path
2121
def exists?(offset: 0)
2222
return false if self.path.include?("\u0000")
2323
return false if (self.id + offset).zero?
24-
File.exists?("#{DIR_PATH}/#{id + offset}.md")
24+
File.exist?("#{DIR_PATH}/#{id + offset}.md")
2525
end
2626

2727
def cover

spec/models/podcast_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919

2020
context 'offset 省略' do
2121
before :each do
22-
allow(File).to receive(:exists?) { false }
22+
allow(File).to receive(:exist?) { false }
2323
end
2424

2525
it 'ファイルあり ⇒ true' do
26-
allow(File).to receive(:exists?).with("public/podcasts/#{@podcast.id}.md") { true }
26+
allow(File).to receive(:exist?).with("public/podcasts/#{@podcast.id}.md") { true }
2727

2828
expect(@podcast.exists?).to eq(true)
2929
end
@@ -35,11 +35,11 @@
3535

3636
context 'offset 指定' do
3737
before :each do
38-
allow(File).to receive(:exists?) { false }
38+
allow(File).to receive(:exist?) { false }
3939
end
4040

4141
it 'ファイルあり ⇒ true' do
42-
allow(File).to receive(:exists?).with("public/podcasts/#{@podcast.id + 1}.md") { true }
42+
allow(File).to receive(:exist?).with("public/podcasts/#{@podcast.id + 1}.md") { true }
4343

4444
expect(@podcast.exists?(offset: 1)).to eq(true)
4545
end

0 commit comments

Comments
 (0)