Rename Remote::FS#{has_,}file?

This commit is contained in:
Thibault Jouan 2014-01-08 22:30:52 +00:00
parent 19b091a15c
commit 103b9d1230
4 changed files with 8 additions and 8 deletions

View File

@ -12,7 +12,7 @@ module Producer
@sftp ||= @remote.session.sftp.connect
end
def has_file?(path)
def file?(path)
sftp.stat!(path).file?
rescue Net::SFTP::StatusException
false

View File

@ -3,7 +3,7 @@ module Producer
module Tests
class HasFile < Test
def verify
env.remote.fs.has_file? arguments.first
env.remote.fs.file? arguments.first
end
end
end

View File

@ -33,7 +33,7 @@ module Producer::Core
# FIXME: We rely a lot on mocking net-sftp heavily, while we already use a
# part of net-ssh story helpers, which are more close to integration tests.
describe '#has_file?', :ssh do
describe '#file?', :ssh do
let(:file_path) { 'some_file_path' }
let(:stat) { double 'stat' }
@ -47,7 +47,7 @@ module Producer::Core
before { allow(stat).to receive(:file?) { true } }
it 'returns true' do
expect(fs.has_file? file_path).to be true
expect(fs.file? file_path).to be true
end
end
@ -55,7 +55,7 @@ module Producer::Core
before { allow(stat).to receive(:file?) { false } }
it 'returns false' do
expect(fs.has_file? file_path).to be false
expect(fs.file? file_path).to be false
end
end
end
@ -68,7 +68,7 @@ module Producer::Core
end
it 'returns false' do
expect(fs.has_file? file_path).to be false
expect(fs.file? file_path).to be false
end
end
end

View File

@ -14,13 +14,13 @@ module Producer::Core
before { sftp_story }
it 'delegates the call on remote FS' do
expect(env.remote.fs).to receive(:has_file?).with(filepath)
expect(env.remote.fs).to receive(:file?).with(filepath)
has_file.verify
end
it 'returns the file existence' do
existence = double 'existence'
allow(env.remote.fs).to receive(:has_file?) { existence }
allow(env.remote.fs).to receive(:file?) { existence }
expect(has_file.verify).to be existence
end
end