spec/config_spec.rb in simple_deploy-0.6.0 vs spec/config_spec.rb in simple_deploy-0.6.1
- old
+ new
@@ -1,34 +1,52 @@
require 'spec_helper'
describe SimpleDeploy do
+ let(:config_data) do
+ { 'environments' => {
+ 'test_env' => {
+ 'secret_key' => 'secret',
+ 'access_key' => 'access',
+ 'region' => 'us-west-1'
+ } },
+ 'notifications' => {
+ 'campfire' => {
+ 'token' => 'my_token'
+ } } }
+ end
- describe "after creating a configuration" do
- before do
- @config_data = { 'artifacts' => {
- 'test_repo' => {
- 'bucket_prefix' => 'test_prefix',
- 'domain' => 'test_domain'
- },
- 'test_repo2' => { },
- },
- 'environments' => {
- 'test_env' => {
- 'secret_key' => 'secret',
- 'access_key' => 'access',
- 'region' => 'us-west-1'
- }
- },
- 'notifications' => {
- 'campfire' => {
- 'token' => 'my_token'
- }
- }
- }
+ describe 'new' do
+ it 'should accept config data as an argument' do
+ YAML.should_not_receive(:load)
+ @config = SimpleDeploy::Config.new :config => config_data
+ @config.config.should == config_data
+ end
+
+ it 'should load the config from ~/.simple_deploy.yml by default' do
File.should_receive(:open).with("#{ENV['HOME']}/.simple_deploy.yml").
- and_return(@config_data.to_yaml)
+ and_return(config_data.to_yaml)
@config = SimpleDeploy::Config.new
+ @config.config.should == config_data
+ end
+
+ it 'should load the config from SIMPLE_DEPLOY_CONFIG_FILE if supplied' do
+ File.should_receive(:open).with("/my/config/file").
+ and_return(config_data.to_yaml)
+ env_mock = mock 'env'
+ SimpleDeploy::Env.stub :new => env_mock
+ env_mock.should_receive(:load).
+ with('SIMPLE_DEPLOY_CONFIG_FILE').
+ and_return "/my/config/file"
+ @config = SimpleDeploy::Config.new
+ @config.config.should == config_data
+ end
+
+ end
+
+ describe "after creating a configuration" do
+ before do
+ @config = SimpleDeploy::Config.new :config => config_data
end
it "should return the default artifacts to deploy" do
@config.artifacts.should == ['chef_repo', 'cookbooks', 'app']
end