spec/config_spec.rb in simple_deploy-0.4.8 vs spec/config_spec.rb in simple_deploy-0.5.0
- old
+ new
@@ -40,22 +40,10 @@
it "should return the Cloud Formation camel case variables" do
@config.artifact_cloud_formation_url('app').should == 'AppArtifactURL'
end
- it "should return the domain (the folder in the s3 bucket) for an artifact" do
- @config.artifact_domain('test_repo').should == 'test_domain'
- end
-
- it "should return the name of an artifact for those without a set domain" do
- @config.artifact_domain('test_repo2').should == 'test_repo2'
- end
-
- it "should return the bucket prefix for the artifact" do
- @config.artifact_bucket_prefix('test_repo').should == 'test_prefix'
- end
-
it "should return the environment requested" do
@config.environment('test_env').should == ({ 'secret_key' => 'secret', 'access_key' => 'access', 'region' => 'us-west-1' })
end
it "should return the notifications available" do
@@ -70,6 +58,39 @@
@config.deploy_script.should == '/opt/intu/admin/bin/configure.sh'
end
end
+ describe "gracefully handling yaml file errors" do
+ before do
+ if File.exists? "#{ENV['HOME']}/.simple_deploy.yml"
+ FileUtils.mv("#{ENV['HOME']}/.simple_deploy.yml",
+ "#{ENV['HOME']}/.simple_deploy.yml.bak")
+ end
+ end
+
+ after do
+ if File.exists? "#{ENV['HOME']}/.simple_deploy.yml.bak"
+ FileUtils.mv("#{ENV['HOME']}/.simple_deploy.yml.bak",
+ "#{ENV['HOME']}/.simple_deploy.yml")
+ end
+ end
+
+ it "should handle a missing file gracefully" do
+ expect {
+ config = SimpleDeploy::Config.new
+ }.to raise_error(RuntimeError, "#{ENV['HOME']}/.simple_deploy.yml not found")
+ end
+
+ it "should handle a corrupt file gracefully" do
+ s = "--\nport:\t80\t80"
+ File.open("#{ENV['HOME']}/.simple_deploy.yml", 'w') do |out|
+ out.write(s)
+ end
+
+ expect {
+ config = SimpleDeploy::Config.new
+ }.to raise_error(RuntimeError, "#{ENV['HOME']}/.simple_deploy.yml is corrupt")
+ FileUtils.rm "#{ENV['HOME']}/.simple_deploy.yml"
+ end
+ end
end