Commit 2eacf29
Changed files (4)
attributes/default.rb
@@ -41,11 +41,12 @@ default['capistrano']['env'] = {
},
newrelic_key: '',
}
-default['delayed_job'] = {
- username: node['user']['username'],
- current_path: "#{node['capistrano']['root_path']}/current",
- rails_env: node.chef_environment,
-}
+default[:delayed_job][:username] = node['user']['username']
+default[:delayed_job][:current_path] = "#{node['capistrano']['root_path']}/current"
+default[:delayed_job][:rails_env] = node.chef_environment
default[:nginx][:domain] = 'www.example.com'
default[:nginx][:current_path] = "#{node['capistrano']['root_path']}/current"
default[:nginx][:shared_path] = "#{node['capistrano']['root_path']}/shared_path"
+default[:unicorn][:username] = node['user']['username']
+default[:unicorn][:current_path] = "#{node['capistrano']['root_path']}/current"
+default[:unicorn][:rails_env] = node.chef_environment
recipes/unicorn.rb
@@ -1,13 +1,13 @@
-configuration = node['unicorn']
+configuration = node[:unicorn]
template "/etc/init.d/unicorn" do
source "unicorn.erb"
- owner configuration['username']
- group configuration['username']
+ owner configuration[:username]
+ group configuration[:username]
mode "0744"
variables(configuration)
end
service "unicorn" do
action [:enable, :start]
-end
+end if File.exists?("#{configuration[:current_path]}/Gemfile")
spec/unicorn_spec.rb
@@ -1,14 +1,15 @@
describe "mokhan-myface::unicorn" do
subject do
ChefSpec::SoloRunner.new do |node|
- node.set['unicorn'] = unicorn_variables
+ node.set['unicorn'] = configuration
end.converge(described_recipe)
end
let(:username) { FFaker::Internet.user_name }
- let(:unicorn_variables) do
+ let(:configuration) do
{
- 'username' => username
+ username: username,
+ current_path: '/tmp',
}
end
@@ -18,10 +19,19 @@ describe "mokhan-myface::unicorn" do
.with_owner(username)
.with_group(username)
.with_mode("0744")
- .with_variables(unicorn_variables)
end
- it 'starts the unicorn service' do
- expect(subject).to start_service("unicorn")
+ context "when the app is deployed" do
+ before :each do
+ FileUtils.touch('/tmp/Gemfile')
+ end
+
+ after :each do
+ FileUtils.rm('/tmp/Gemfile')
+ end
+
+ it 'starts the unicorn service' do
+ expect(subject).to start_service("unicorn")
+ end
end
end
.kitchen.yml
@@ -15,5 +15,5 @@ suites:
- recipe[mokhan-myface::capistrano]
- recipe[mokhan-myface::delayed_job]
- recipe[mokhan-myface::nginx]
- #- recipe[mokhan-myface::unicorn]
+ - recipe[mokhan-myface::unicorn]
attributes: