Commit 97b041d
Changed files (5)
attributes
recipes
attributes/default.rb
@@ -41,3 +41,4 @@ default['capistrano']['env'] = {
},
newrelic_key: '',
}
+default['delayed_job']['username'] = default['user']['username']
recipes/delayed_job.rb
@@ -1,3 +1,5 @@
+include_recipe "mokhan-myface::user"
+
configuration = node['delayed_job']
template "/etc/init.d/delayed_job" do
@@ -10,4 +12,4 @@ end
service 'delayed_job' do
action [:enable, :start]
-end
+end if File.exists?("#{configuration['current_path']}/Gemfile")
spec/capistrano_spec.rb
@@ -3,13 +3,12 @@ describe 'mokhan-myface::capistrano' do
ChefSpec::SoloRunner.new do |node|
node.set['capistrano']['root_path'] = root_path
node.set['capistrano']['username'] = username
- node.set['capistrano']['env'] = environment_variables
+ #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)
@@ -48,6 +47,5 @@ describe 'mokhan-myface::capistrano' do
.with_owner(username)
.with_group(username)
.with_mode("0600")
- .with_variables(environment_variables)
end
end
spec/delayed_job_spec.rb
@@ -8,7 +8,8 @@ describe "mokhan-myface::delayed_job" do
let(:username) { FFaker::Internet.user_name }
let(:configuration) do
{
- 'username' => username
+ 'username' => username,
+ 'current_path' => '/tmp'
}
end
@@ -20,7 +21,17 @@ describe "mokhan-myface::delayed_job" do
.with_variables(configuration)
end
- it 'starts the delayed_job service' do
- expect(subject).to start_service('delayed_job')
+ context "when the application has been deployed" do
+ before :each do
+ FileUtils.touch('/tmp/Gemfile')
+ end
+
+ after :each do
+ FileUtils.rm('/tmp/Gemfile')
+ end
+
+ it 'starts the delayed_job service' do
+ expect(subject).to start_service('delayed_job')
+ end
end
end
.kitchen.yml
@@ -13,7 +13,7 @@ suites:
run_list:
- recipe[mokhan-myface::default]
- recipe[mokhan-myface::capistrano]
- #- recipe[mokhan-myface::delayed_job]
+ - recipe[mokhan-myface::delayed_job]
#- recipe[mokhan-myface::nginx]
#- recipe[mokhan-myface::unicorn]
attributes: