Improve small details in specs:
* Fix coding standards; * Simplify some expectations (eq instead of be matcher); * Expect identity on block instead of calling; * Change some before call as oneliners; * Avoid shadowing variable names; * Improve wording where needed.
This commit is contained in:
@@ -15,12 +15,12 @@ module Producer::Core
|
||||
before { sftp_story }
|
||||
|
||||
it 'builds a new SFTP session' do
|
||||
expect(remote.session.sftp).to receive(:connect)
|
||||
expect(remote.session.sftp).to receive :connect
|
||||
fs.sftp
|
||||
end
|
||||
|
||||
it 'returns the new SFTP session' do
|
||||
session = double('session')
|
||||
session = double 'session'
|
||||
allow(remote.session.sftp).to receive(:connect) { session }
|
||||
expect(fs.sftp).to be session
|
||||
end
|
||||
@@ -35,7 +35,7 @@ module Producer::Core
|
||||
# part of net-ssh story helpers, which are more close to integration tests.
|
||||
describe '#has_file?', :ssh do
|
||||
let(:file_path) { "some_file_path" }
|
||||
let(:stat) { double('stat') }
|
||||
let(:stat) { double 'stat' }
|
||||
|
||||
before do
|
||||
sftp_story
|
||||
@@ -44,35 +44,31 @@ module Producer::Core
|
||||
|
||||
context 'when path given as argument exists' do
|
||||
context 'when path is a file' do
|
||||
before do
|
||||
allow(stat).to receive(:file?) { true }
|
||||
end
|
||||
before { allow(stat).to receive(:file?) { true } }
|
||||
|
||||
it 'returns true' do
|
||||
expect(fs.has_file?(file_path)).to be true
|
||||
expect(fs.has_file? file_path).to be true
|
||||
end
|
||||
end
|
||||
|
||||
context 'when path is not a file' do
|
||||
before do
|
||||
allow(stat).to receive(:file?) { false }
|
||||
end
|
||||
before { allow(stat).to receive(:file?) { false } }
|
||||
|
||||
it 'returns false' do
|
||||
expect(fs.has_file?(file_path)).to be false
|
||||
expect(fs.has_file? file_path).to be false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when querying the path raises a Net::SFTP::StatusException' do
|
||||
before do
|
||||
response = double('response', code: '42', message: 'some message')
|
||||
response = double 'response', code: '42', message: 'some message'
|
||||
ex = Net::SFTP::StatusException.new(response)
|
||||
allow(stat).to receive(:file?).and_raise(ex)
|
||||
end
|
||||
|
||||
it 'returns false' do
|
||||
expect(fs.has_file?(file_path)).to be false
|
||||
expect(fs.has_file? file_path).to be false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user