summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2015-05-02 12:11:43 -0600
committermo khan <mo@mokhan.ca>2015-05-02 12:11:43 -0600
commit46a1cb08d5d849b2b75bf0ddd43d17c9489caaed (patch)
tree6437bd0dca7f3f43531e0bb2b4eb2afc5bb28e55 /spec
parenteeea730a41414355bc46fac8094d9dd8fe8b36ef (diff)
add capistrano recipe.
Diffstat (limited to 'spec')
-rw-r--r--spec/capistrano_spec.rb53
-rw-r--r--spec/spec_helper.rb1
2 files changed, 54 insertions, 0 deletions
diff --git a/spec/capistrano_spec.rb b/spec/capistrano_spec.rb
new file mode 100644
index 0000000..2e23d19
--- /dev/null
+++ b/spec/capistrano_spec.rb
@@ -0,0 +1,53 @@
+describe 'mokhan-myface::capistrano' do
+ subject do
+ ChefSpec::SoloRunner.new do |node|
+ node.set['capistrano']['root_path'] = root_path
+ node.set['capistrano']['username'] = username
+ node.set['capistrano']['env'] = environment_variables
+ end.converge(described_recipe)
+ end
+ let(:root_path) { "/var/www/#{FFaker::Internet.domain_name}" }
+ let(:shared_path) { "#{root_path}/shared" }
+ let(:username) { 'deployer' }
+ let(:environment_variables) { Hash.new }
+
+ it 'creates the root directory for the application' do
+ expect(subject).to create_directory(root_path)
+ .with_owner(username)
+ .with_group(username)
+ .with_mode("0755")
+ end
+
+ it 'creates the shared directory for the application' do
+ expect(subject).to create_directory("#{root_path}/shared")
+ .with_owner(username)
+ .with_group(username)
+ .with_mode("0755")
+ end
+
+ it 'creates all the shared folders' do
+ directories = [
+ "#{shared_path}/backups",
+ "#{shared_path}/bundle",
+ "#{shared_path}/config",
+ "#{shared_path}/log",
+ "#{shared_path}/pids",
+ "#{shared_path}/sockets",
+ "#{root_path}/releases"
+ ]
+ directories.each do |directory|
+ expect(subject).to create_directory(directory)
+ .with_owner(username)
+ .with_group(username)
+ .with_mode("0755")
+ end
+ end
+
+ it 'lays down the .env template' do
+ expect(subject).to create_template("#{shared_path}/.env")
+ .with_owner(username)
+ .with_group(username)
+ .with_mode("0600")
+ .with_variables(environment_variables)
+ end
+end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 7027d0f..9ec369a 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -12,6 +12,7 @@
# the additional setup, and require it from the spec files that actually need
# it.
require 'chefspec'
+require 'ffaker'
# The `.rspec` file also contains a few flags that are not defaults but that
# users commonly want.