Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finish replacing deprecated File.exists? with File.exist? #1233

Merged
merged 2 commits into from
Sep 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/thinking_sphinx/commands/clear_real_time.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def call
Dir["#{index.path}.*"].each { |path| FileUtils.rm path }
end

FileUtils.rm_r(binlog_path) if File.exists?(binlog_path)
FileUtils.rm_r(binlog_path) if File.exist?(binlog_path)
end

private
Expand Down
2 changes: 1 addition & 1 deletion lib/thinking_sphinx/settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def initialize(configuration)
end

def call
return defaults unless File.exists? file
return defaults unless File.exist? file

merged.inject({}) do |hash, (key, value)|
if absolute_key?(key)
Expand Down
7 changes: 6 additions & 1 deletion spec/support/sphinx_yaml_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@

module SphinxYamlHelpers
def write_configuration(hash)
allow(File).to receive_messages :read => {'test' => hash}.to_yaml, :exists? => true
allow(File).to receive(:read).and_return({'test' => hash}.to_yaml)
allow(File).to receive(:exist?).and_wrap_original do |original, path|
next true if path.to_s == File.absolute_path("config/thinking_sphinx.yml", Rails.root.to_s)

original.call(path)
end
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/thinking_sphinx/commands/clear_real_time_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

allow(FileUtils).to receive_messages :rm_r => true,
:rm => true
allow(File).to receive_messages :exists? => true
allow(File).to receive_messages :exist? => true
end

it 'finds each file for real-time indices' do
Expand Down
2 changes: 1 addition & 1 deletion spec/thinking_sphinx/commands/clear_sql_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
and_return(['/path/to/indices/ts-foo.tmp'])

allow(FileUtils).to receive_messages :rm_r => true, :rm => true
allow(File).to receive_messages :exists? => true
allow(File).to receive_messages :exist? => true
end

it 'finds each file for sql-backed indices' do
Expand Down
19 changes: 16 additions & 3 deletions spec/thinking_sphinx/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@ def expect_loading_of(file)
end

it 'does not cache settings after reset' do
allow(File).to receive_messages :exists? => true
allow(File).to receive(:exist?).and_wrap_original do |original, path|
next true if path.to_s == File.absolute_path("config/thinking_sphinx.yml", Rails.root)

original.call(path)
end

allow(File).to receive_messages :read => {
'test' => {'foo' => 'bugs'},
'production' => {'foo' => 'bar'}
Expand Down Expand Up @@ -504,7 +509,11 @@ def expect_loading_of(file)
describe '#settings' do
context 'YAML file exists' do
before :each do
allow(File).to receive_messages :exists? => true
allow(File).to receive(:exist?).and_wrap_original do |original, path|
next true if path.to_s == File.absolute_path("config/thinking_sphinx.yml", Rails.root)

original.call(path)
end
end

it "reads from the YAML file" do
Expand Down Expand Up @@ -540,7 +549,11 @@ def expect_loading_of(file)

context 'YAML file does not exist' do
before :each do
allow(File).to receive_messages :exists? => false
allow(File).to receive(:exist?).and_wrap_original do |original, path|
next false if path.to_s == File.absolute_path("config/thinking_sphinx.yml", Rails.root)

original.call(path)
end
end

it "does not read the file" do
Expand Down