Update rspec and fix tests

Change-Id: I4e3f1de45899c99ffb3d7c950385bd873b7ffede
This commit is contained in:
Dmitry Ilyin 2016-02-18 16:06:11 +03:00 committed by Vladimir Sharshov (warpc)
parent f36f65b483
commit baf1d3bb7e
9 changed files with 37 additions and 30 deletions

View File

@ -22,7 +22,7 @@ Gem::Specification.new do |s|
s.add_development_dependency 'facter'
s.add_development_dependency 'rake', '10.0.4'
s.add_development_dependency 'rspec', '2.13.0'
s.add_development_dependency 'rspec', '>= 3.4.0'
s.add_development_dependency 'mocha', '0.13.3'
s.add_development_dependency 'simplecov', '~> 0.7.1'
s.add_development_dependency 'simplecov-rcov', '~> 0.2.3'

View File

@ -211,7 +211,7 @@ describe Cobbler do
cobbler = Astute::Provision::Cobbler.new
cobbler.stubs(:sleep).with(10).times(1)
expect { cobbler.sync }.to_not raise_exception(Net::ReadTimeout)
expect { cobbler.sync }.not_to raise_exception(Net::ReadTimeout)
end
it 'should try sync several time before raise a exception (XMLRPC)' do
@ -227,7 +227,7 @@ describe Cobbler do
cobbler = Astute::Provision::Cobbler.new
cobbler.stubs(:sleep).with(10).times(1)
expect { cobbler.sync }.to_not raise_exception(XMLRPC::FaultException)
expect { cobbler.sync }.not_to raise_exception(XMLRPC::FaultException)
end
it 'should raise a exception if sync do not succeed after several(3) tries' do

View File

@ -48,7 +48,7 @@ describe Astute::DeploymentEngine do
end
it 'should be avaliable as superclass' do
expect { Engine.new(ctx) }.to be_true
expect(Engine.new(ctx)).to be_truthy
end
end

View File

@ -682,7 +682,9 @@ describe Astute::NailgunHooks do
.then.raises(Astute::MClientError)
.then.returns([mc_result('3', true)])
expect {hooks.process}.to_not raise_error(Astute::DeploymentEngineError)
expect {
hooks.process
}.not_to raise_error(Astute::DeploymentEngineError)
end
it 'should fail if it still raise error after retries' do

View File

@ -108,8 +108,9 @@ describe Astute::UploadCirrosImage do
.returns(:data => {:exit_code => 1}).times(5)
upload_cirros_image.stubs(:sleep).with(10).times(4)
expect {upload_cirros_image.process(deploy_data, ctx)}
.to_not raise_error(Astute::CirrosError)
expect {
upload_cirros_image.process(deploy_data, ctx)
}.not_to raise_error(Astute::CirrosError)
end
it 'should not send node error status for last node and raise if deploy \
@ -121,8 +122,9 @@ describe Astute::UploadCirrosImage do
.returns(:data => {:exit_code => 1}).times(5)
upload_cirros_image.stubs(:sleep).with(10).times(4)
expect {upload_cirros_image.process([deploy_data.last], ctx)}
.to_not raise_error(Astute::CirrosError)
expect {
upload_cirros_image.process([deploy_data.last], ctx)
}.not_to raise_error(Astute::CirrosError)
end
it 'should try to add image again if we only add new nodes \
@ -137,7 +139,7 @@ describe Astute::UploadCirrosImage do
upload_cirros_image.stubs(:run_shell_command)
.returns(:data => {:exit_code => 0})
.then.returns(:data => {:exit_code => 0})
expect(upload_cirros_image.process(deploy_data, ctx)).to be_true
expect(upload_cirros_image.process(deploy_data, ctx)).to eq true
end
it 'should add new image if cluster deploy success and \
@ -145,7 +147,7 @@ describe Astute::UploadCirrosImage do
upload_cirros_image.stubs(:run_shell_command)
.returns(:data => {:exit_code => 0})
.then.returns(:data => {:exit_code => 0})
expect(upload_cirros_image.process(deploy_data, ctx)).to be_true
expect(upload_cirros_image.process(deploy_data, ctx)).to eq true
end
it 'should send node error status for controller and raise if deploy \
@ -209,4 +211,4 @@ describe Astute::UploadCirrosImage do
upload_cirros_image.process(deploy_data, ctx)
end
end #'upload_cirros_image'
end #'upload_cirros_image'

View File

@ -44,14 +44,14 @@ describe Astute::GenerateKeys do
end
it 'should save files in correct place: KEY_DIR/<name of key>/' do
it 'should save files in correct place: KEY_DIR/<uid>/<name of key>/' do
generate_keys.stubs(:run_system_command).returns([0, "", ""])
Dir.mktmpdir do |temp_dir|
Astute.config.keys_src_dir = temp_dir
generate_keys.process(deploy_data, ctx)
expect { File.directory? File.join(temp_dir, 'mongodb.key') }.to be_true
key_dir = File.join(temp_dir, deploy_data.first['uid'].to_s, 'mongodb')
expect(File.directory? key_dir).to eq true
end
end
@ -100,13 +100,14 @@ describe Astute::GenerateKeys do
it 'should not overwrite files' do
Dir.mktmpdir do |temp_dir|
Astute.config.keys_src_dir = temp_dir
key_path = File.join(temp_dir,'mongodb', 'mongodb.key')
FileUtils.mkdir_p File.join(temp_dir, 'mongodb')
key_dir = File.join(temp_dir, deploy_data.first['uid'].to_s, 'mongodb')
key_path = File.join(key_dir, 'mongodb.key')
FileUtils.mkdir_p key_dir
File.open(key_path, 'w') { |file| file.write("say no overwrite") }
generate_keys.process(deploy_data, ctx)
expect { File.exist? File.join(key_path, 'mongodb', 'mongodb.key') }.to be_true
expect { File.read File.join(key_path, 'mongodb', 'mongodb.key') == "say no overwrite" }.to be_true
expect(File.exist? key_path).to eq true
expect(File.read key_path).to eq 'say no overwrite'
end
end
@ -136,4 +137,4 @@ describe Astute::GenerateKeys do
generate_keys.process(deploy_data, ctx)
end
end
end

View File

@ -44,14 +44,15 @@ describe Astute::GenerateSshKeys do
end
it 'should save files in correct place: KEY_DIR/<name of key>/' do
it 'should save files in correct place: KEY_DIR/<uid>/<name of key>/' do
generate_ssh_keys.stubs(:run_system_command).returns([0, "", ""])
Dir.mktmpdir do |temp_dir|
Astute.config.keys_src_dir = temp_dir
generate_ssh_keys.process(deploy_data, ctx)
key_dir = File.join(temp_dir, deploy_data.first['uid'].to_s, 'nova')
expect { File.directory? File.join(temp_dir, 'nova') }.to be_true
expect(File.directory? key_dir).to eq true
end
end
@ -95,13 +96,14 @@ describe Astute::GenerateSshKeys do
it 'should not overwrite files' do
Dir.mktmpdir do |temp_dir|
Astute.config.keys_src_dir = temp_dir
key_path = File.join(temp_dir,'nova', 'nova')
FileUtils.mkdir_p File.join(temp_dir,'nova')
key_dir = File.join(temp_dir, deploy_data.first['uid'].to_s, 'nova')
key_path = File.join(key_dir, 'nova')
FileUtils.mkdir_p key_dir
File.open(key_path, 'w') { |file| file.write("say no overwrite") }
generate_ssh_keys.process(deploy_data, ctx)
expect { File.exist? File.join(key_path, 'nova', 'nova') }.to be_true
expect { File.read File.join(key_path, 'nova', 'nova') == "say no overwrite" }.to be_true
expect(File.exist? key_path).to eq true
expect(File.read key_path).to eq 'say no overwrite'
end
end
@ -121,4 +123,4 @@ describe Astute::GenerateSshKeys do
generate_ssh_keys.process(deploy_data, ctx)
end
end
end

View File

@ -81,7 +81,7 @@ describe Astute::SyncPuppetStuff do
Astute::MClient.any_instance.stubs(:check_results_with_retries)
.raises(Astute::MClientError)
.then.returns("")
expect { sync_puppet_stuff.process(nodes, ctx) }.to_not raise_error(Astute::MClientError)
expect { sync_puppet_stuff.process(nodes, ctx) }.not_to raise_error(Astute::MClientError)
end
end

View File

@ -89,8 +89,8 @@ describe Astute::TaskDeployment do
it 'should support virtual node' do
d_t = task_deployment.send(:support_virtual_node, deployment_tasks)
expect(d_t.keys.include?('virtual_sync_node')).to be_true
expect(d_t.keys.include?('null')).to be_false
expect(d_t.keys).to include 'virtual_sync_node'
expect(d_t.keys).not_to include 'null'
end
it 'should remove failed nodes' do