depengine 3.0.20 → 3.0.21
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +8 -0
- data/.rubocop_todo.yml +52 -0
- data/Gemfile.lock +16 -1
- data/Rakefile +9 -9
- data/bin/cdb_crypt +2 -2
- data/bin/de +1 -1
- data/bin/depengine +2 -2
- data/bin/spec_setup +2 -2
- data/depengine.gemspec +22 -21
- data/lib/depengine/asserter/url.rb +8 -9
- data/lib/depengine/cli.rb +12 -14
- data/lib/depengine/dsl/cdb.rb +16 -17
- data/lib/depengine/dsl/deployment.rb +42 -50
- data/lib/depengine/dsl/dweb.rb +10 -11
- data/lib/depengine/dsl/executor.rb +5 -5
- data/lib/depengine/dsl/fileops.rb +3 -4
- data/lib/depengine/dsl/helper.rb +26 -28
- data/lib/depengine/dsl/iis.rb +21 -24
- data/lib/depengine/dsl/patch.rb +22 -46
- data/lib/depengine/dsl/publisher.rb +14 -14
- data/lib/depengine/dsl/remote.rb +11 -13
- data/lib/depengine/dsl/repository.rb +19 -21
- data/lib/depengine/dsl/template.rb +19 -19
- data/lib/depengine/dsl/zip.rb +24 -24
- data/lib/depengine/helper/cli_helper.rb +9 -11
- data/lib/depengine/helper/hudson.rb +15 -19
- data/lib/depengine/helper/mail.rb +19 -25
- data/lib/depengine/helper/properties.rb +33 -52
- data/lib/depengine/helper/smb.rb +19 -25
- data/lib/depengine/helper/validations.rb +7 -7
- data/lib/depengine/helper/yaml.rb +7 -9
- data/lib/depengine/log/log.rb +3 -6
- data/lib/depengine/processor/erb_template.rb +42 -47
- data/lib/depengine/processor/fileops.rb +39 -48
- data/lib/depengine/processor/local_execute.rb +6 -4
- data/lib/depengine/processor/properties.rb +34 -56
- data/lib/depengine/processor/sed.rb +8 -12
- data/lib/depengine/processor/tags.rb +9 -10
- data/lib/depengine/processor/template.rb +27 -32
- data/lib/depengine/processor/zip.rb +16 -20
- data/lib/depengine/provider/cdb.rb +64 -71
- data/lib/depengine/provider/cdb_filesystem.rb +18 -26
- data/lib/depengine/provider/git.rb +37 -42
- data/lib/depengine/provider/repository.rb +161 -176
- data/lib/depengine/publisher/dweb.rb +74 -90
- data/lib/depengine/publisher/iis.rb +23 -30
- data/lib/depengine/publisher/rsync.rb +14 -17
- data/lib/depengine/publisher/samba.rb +12 -14
- data/lib/depengine/publisher/sftp.rb +51 -61
- data/lib/depengine/publisher/ssh.rb +19 -22
- data/lib/depengine/publisher/tomcat.rb +19 -21
- data/lib/depengine/reporter/cdb.rb +2 -3
- data/lib/depengine/version.rb +1 -1
- data/lib/depengine.rb +1 -2
- data/spec/cdb_spec.rb +8 -10
- data/spec/demo_recipe/recipes/demo.rb +10 -10
- data/spec/deployhelper_spec.rb +20 -21
- data/spec/fileops_spec.rb +11 -12
- data/spec/git_spec.rb +8 -4
- data/spec/helper_spec.rb +75 -75
- data/spec/junit.rb +47 -49
- data/spec/local_execute.rb +7 -7
- data/spec/log_spec.rb +17 -18
- data/spec/properties_spec.rb +13 -15
- data/spec/recipe_spec.rb +15 -16
- data/spec/repository_spec.rb +20 -20
- data/spec/ssh_spec.rb +18 -19
- data/spec/template_spec.rb +30 -30
- data/spec/zip_spec.rb +7 -7
- metadata +18 -2
data/spec/helper_spec.rb
CHANGED
@@ -1,22 +1,22 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) +
|
1
|
+
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + '/../lib'))
|
2
2
|
require 'depengine'
|
3
3
|
require 'depengine/cli'
|
4
4
|
require 'tmpdir'
|
5
5
|
require 'fileutils'
|
6
6
|
|
7
|
-
describe
|
7
|
+
describe 'the date_unique method' do
|
8
8
|
|
9
9
|
before :each do
|
10
10
|
$recipe_config_backup = $recipe_config
|
11
11
|
$recipe_config = {
|
12
|
-
:
|
13
|
-
:
|
14
|
-
:
|
15
|
-
:
|
16
|
-
:
|
17
|
-
:
|
18
|
-
:
|
19
|
-
:
|
12
|
+
deploy_home: '/tmp/deploy_home',
|
13
|
+
recipe_base_dir: '/tmp/recipe_base_dir',
|
14
|
+
env: 'TEST',
|
15
|
+
version: '42.23.0',
|
16
|
+
log_level: 'ERROR',
|
17
|
+
skip_cdb_setup: true,
|
18
|
+
application_name: 'testenvapp',
|
19
|
+
module_name: 'testenvmodule'
|
20
20
|
}
|
21
21
|
end
|
22
22
|
|
@@ -24,15 +24,15 @@ describe "the date_unique method" do
|
|
24
24
|
$recipe_config = $recipe_config_backup
|
25
25
|
end
|
26
26
|
|
27
|
-
it
|
28
|
-
expect(Deployment::Worker.new.date_unique(
|
27
|
+
it 'should use a specified format' do
|
28
|
+
expect(Deployment::Worker.new.date_unique('%Y')).to match(/^\d{4}$/)
|
29
29
|
end
|
30
30
|
|
31
|
-
it
|
32
|
-
expect(Deployment::Worker.new.date_unique).to match
|
31
|
+
it 'should have a default format' do
|
32
|
+
expect(Deployment::Worker.new.date_unique).to match(/^\d{4}-\d{2}-\d{2}_\d+$/)
|
33
33
|
end
|
34
34
|
|
35
|
-
it
|
35
|
+
it 'should cache its object' do
|
36
36
|
w = Deployment::Worker.new
|
37
37
|
first = w.date_unique
|
38
38
|
sleep(1)
|
@@ -41,18 +41,18 @@ describe "the date_unique method" do
|
|
41
41
|
|
42
42
|
end
|
43
43
|
|
44
|
-
describe
|
44
|
+
describe 'the copy_to_workspace method' do
|
45
45
|
before :each do
|
46
46
|
$recipe_config_backup = $recipe_config
|
47
47
|
$recipe_config = {
|
48
|
-
:
|
49
|
-
:
|
50
|
-
:
|
51
|
-
:
|
52
|
-
:
|
53
|
-
:
|
54
|
-
:
|
55
|
-
:
|
48
|
+
deploy_home: Dir.tmpdir,
|
49
|
+
recipe_base_dir: File.expand_path(File.dirname(__FILE__) + '/demo_recipe/'),
|
50
|
+
env: 'TEST',
|
51
|
+
version: '42.23.0',
|
52
|
+
log_level: 'ERROR',
|
53
|
+
skip_cdb_setup: true,
|
54
|
+
application_name: 'testenvapp',
|
55
|
+
module_name: 'testenvmodule'
|
56
56
|
}
|
57
57
|
end
|
58
58
|
|
@@ -61,42 +61,42 @@ describe "the copy_to_workspace method" do
|
|
61
61
|
$recipe_config = $recipe_config_backup
|
62
62
|
end
|
63
63
|
|
64
|
-
context
|
65
|
-
it
|
66
|
-
$recipe_config[:copy_to_workspace] = [
|
64
|
+
context 'given an array of directories' do
|
65
|
+
it 'should copy all direcotries' do
|
66
|
+
$recipe_config[:copy_to_workspace] = ['config']
|
67
67
|
Deployment::Worker.new
|
68
|
-
expect(File.directory?(File.join($recipe_config[:deploy_home],
|
69
|
-
expect(File.file?(File.join($recipe_config[:deploy_home],
|
68
|
+
expect(File.directory?(File.join($recipe_config[:deploy_home], 'config'))).to be true
|
69
|
+
expect(File.file?(File.join($recipe_config[:deploy_home], 'config', 'config.properties'))).to be true
|
70
70
|
end
|
71
71
|
end
|
72
|
-
context
|
73
|
-
it
|
72
|
+
context 'set to a truthy object' do
|
73
|
+
it 'should copy the config/ dir' do
|
74
74
|
$recipe_config[:copy_to_workspace] = true
|
75
75
|
Deployment::Worker.new
|
76
|
-
expect(File.file?(File.join($recipe_config[:deploy_home],
|
76
|
+
expect(File.file?(File.join($recipe_config[:deploy_home], 'config', 'config.properties'))).to be true
|
77
77
|
end
|
78
78
|
end
|
79
|
-
context
|
80
|
-
it
|
79
|
+
context 'not given' do
|
80
|
+
it 'should not copy anything' do
|
81
81
|
$recipe_config[:copy_to_workspace] = nil
|
82
82
|
Deployment::Worker.new
|
83
|
-
expect(File.file?(File.join($recipe_config[:deploy_home],
|
83
|
+
expect(File.file?(File.join($recipe_config[:deploy_home], 'config', 'config.properties'))).to be false
|
84
84
|
end
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
88
|
-
describe
|
88
|
+
describe 'the report_by_mail method' do
|
89
89
|
before :each do
|
90
90
|
$recipe_config_backup = $recipe_config
|
91
91
|
$recipe_config = {
|
92
|
-
:
|
93
|
-
:
|
94
|
-
:
|
95
|
-
:
|
96
|
-
:
|
97
|
-
:
|
98
|
-
:
|
99
|
-
:
|
92
|
+
deploy_home: Dir.tmpdir,
|
93
|
+
recipe_base_dir: File.expand_path(File.dirname(__FILE__) + '/demo_recipe/'),
|
94
|
+
env: 'TEST',
|
95
|
+
version: '42.23.0',
|
96
|
+
log_level: 'ERROR',
|
97
|
+
skip_cdb_setup: true,
|
98
|
+
application_name: 'testenvapp',
|
99
|
+
module_name: 'testenvmodule'
|
100
100
|
}
|
101
101
|
end
|
102
102
|
after :each do
|
@@ -104,43 +104,43 @@ describe "the report_by_mail method" do
|
|
104
104
|
$recipe_config = $recipe_config_backup
|
105
105
|
end
|
106
106
|
|
107
|
-
it
|
107
|
+
it 'should send a automatically filled mail via smtp' do
|
108
108
|
worker = Deployment::Worker.new
|
109
109
|
worker.cdb['deploy_email_from'] = "#{ENV['USER']}@localhost"
|
110
110
|
worker.cdb['deploy_email_to'] = "#{ENV['USER']}@localhost"
|
111
|
-
expect {worker.report_by_mail
|
111
|
+
expect { worker.report_by_mail }.to_not raise_error
|
112
112
|
end
|
113
113
|
|
114
|
-
it
|
114
|
+
it 'should send a manually filled mail via smtp' do
|
115
115
|
worker = Deployment::Worker.new
|
116
116
|
h = {
|
117
|
-
:
|
118
|
-
:
|
119
|
-
:
|
120
|
-
:
|
121
|
-
:
|
122
|
-
:
|
117
|
+
application_name: 'thisisjustatestapplication',
|
118
|
+
module_name: 'andthisatestmodule',
|
119
|
+
status: 'somewhatsuccessful',
|
120
|
+
message: 'i dont know what could possibly go wrong',
|
121
|
+
deploy_email_from: "#{ENV['USER']}@localhost",
|
122
|
+
deploy_email_to: "#{ENV['USER']}@localhost"
|
123
123
|
}
|
124
|
-
expect {worker.report_by_mail(h)}.to_not raise_error
|
124
|
+
expect { worker.report_by_mail(h) }.to_not raise_error
|
125
125
|
end
|
126
126
|
|
127
|
-
it
|
127
|
+
it 'does set a subject' do
|
128
128
|
worker = Deployment::Worker.new
|
129
129
|
h = {
|
130
|
-
:
|
131
|
-
:
|
132
|
-
:
|
133
|
-
:
|
134
|
-
:
|
135
|
-
:
|
136
|
-
:
|
130
|
+
application_name: 'testapplication',
|
131
|
+
module_name: 'testmodule',
|
132
|
+
job_name: 'testjob',
|
133
|
+
status: 'SUCCESS',
|
134
|
+
message: 'i dont know what could possibly go wrong',
|
135
|
+
deploy_email_from: "#{ENV['USER']}@localhost",
|
136
|
+
deploy_email_to: "#{ENV['USER']}@localhost"
|
137
137
|
}
|
138
138
|
expect(worker).to receive(:sendmail).once.with(
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
139
|
+
to: h[:deploy_email_to],
|
140
|
+
from: h[:deploy_email_from],
|
141
|
+
subject: 'TEST testjob testmodule testapplication 42.23.0 SUCCESS',
|
142
|
+
body: kind_of(String)
|
143
|
+
|
144
144
|
)
|
145
145
|
worker.report_by_mail(h)
|
146
146
|
end
|
@@ -149,18 +149,18 @@ describe "the report_by_mail method" do
|
|
149
149
|
it 'does include the git history in the message object' do
|
150
150
|
worker = Deployment::Worker.new
|
151
151
|
h = {
|
152
|
-
:
|
153
|
-
:
|
154
|
-
:
|
155
|
-
:
|
156
|
-
:
|
157
|
-
:
|
158
|
-
:
|
152
|
+
application_name: 'testapplication',
|
153
|
+
module_name: 'testmodule',
|
154
|
+
job_name: 'testjob',
|
155
|
+
status: 'SUCCESS',
|
156
|
+
message: 'i dont know what could possibly go wrong',
|
157
|
+
deploy_email_from: "#{ENV['USER']}@localhost",
|
158
|
+
deploy_email_to: "#{ENV['USER']}@localhost"
|
159
159
|
}
|
160
160
|
git_history = "825dc42 foo improved\ne626123 bar renamed\n"
|
161
161
|
allow(Processor).to receive(:local_execute).and_return(git_history)
|
162
162
|
expect(worker).to receive(:report_by_mail).once.with(
|
163
|
-
h.merge(
|
163
|
+
h.merge(message: h[:message] + git_history)
|
164
164
|
)
|
165
165
|
worker.report_by_mail_with_git_history('', '', h)
|
166
166
|
end
|
data/spec/junit.rb
CHANGED
@@ -1,86 +1,84 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
=end
|
1
|
+
#
|
2
|
+
# Copyright (c) 2012, Nathaniel Ritmeyer
|
3
|
+
# All rights reserved.
|
4
|
+
#
|
5
|
+
# Redistribution and use in source and binary forms, with or without
|
6
|
+
# modification, are permitted provided that the following conditions are met:
|
7
|
+
#
|
8
|
+
# 1. Redistributions of source code must retain the above copyright notice,
|
9
|
+
# this list of conditions and the following disclaimer.
|
10
|
+
#
|
11
|
+
# 2. Redistributions in binary form must reproduce the above copyright
|
12
|
+
# notice, this list of conditions and the following disclaimer in the
|
13
|
+
# documentation and/or other materials provided with the distribution.
|
14
|
+
#
|
15
|
+
# 3. Neither the name Nathaniel Ritmeyer nor the names of contributors to
|
16
|
+
# this software may be used to endorse or promote products derived from this
|
17
|
+
# software without specific prior written permission.
|
18
|
+
#
|
19
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
|
20
|
+
# IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
21
|
+
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
22
|
+
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
|
23
|
+
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
24
|
+
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
25
|
+
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
26
|
+
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
27
|
+
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
28
|
+
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
29
|
+
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
30
|
+
#
|
33
31
|
|
34
32
|
require 'time'
|
35
33
|
require 'builder'
|
36
34
|
require 'rspec/core/formatters/base_formatter'
|
37
35
|
|
38
36
|
class JUnit < RSpec::Core::Formatters::BaseFormatter
|
39
|
-
def initialize
|
37
|
+
def initialize(output)
|
40
38
|
super output
|
41
39
|
@test_results = []
|
42
40
|
end
|
43
41
|
|
44
|
-
def example_passed
|
42
|
+
def example_passed(example)
|
45
43
|
@test_results << example
|
46
44
|
end
|
47
45
|
|
48
|
-
def example_failed
|
46
|
+
def example_failed(example)
|
49
47
|
@test_results << example
|
50
48
|
end
|
51
49
|
|
52
|
-
def example_pending
|
50
|
+
def example_pending(example)
|
53
51
|
@test_results << example
|
54
52
|
end
|
55
53
|
|
56
|
-
def failure_details_for
|
54
|
+
def failure_details_for(example)
|
57
55
|
exception = example.metadata[:execution_result][:exception]
|
58
|
-
exception.nil? ?
|
56
|
+
exception.nil? ? '' : "#{exception.message}\n#{format_backtrace(exception.backtrace, example).join("\n")}"
|
59
57
|
end
|
60
58
|
|
61
|
-
def full_name_for
|
62
|
-
test_name =
|
59
|
+
def full_name_for(example)
|
60
|
+
test_name = ''
|
63
61
|
current_example_group = example.metadata[:example_group]
|
64
|
-
until current_example_group.nil?
|
62
|
+
until current_example_group.nil?
|
65
63
|
test_name = "#{current_example_group[:description]}." + test_name
|
66
64
|
current_example_group = current_example_group[:example_group]
|
67
65
|
end
|
68
66
|
test_name << example.metadata[:description]
|
69
67
|
end
|
70
68
|
|
71
|
-
def dump_summary
|
72
|
-
builder = Builder::XmlMarkup.new :
|
73
|
-
builder.instruct! :xml, :
|
74
|
-
builder.testsuite :
|
69
|
+
def dump_summary(duration, example_count, failure_count, pending_count)
|
70
|
+
builder = Builder::XmlMarkup.new indent: 2
|
71
|
+
builder.instruct! :xml, version: '1.0', encoding: 'UTF-8'
|
72
|
+
builder.testsuite errors: 0, failures: failure_count, skipped: pending_count, tests: example_count, time: duration, timestamp: Time.now.iso8601 do
|
75
73
|
builder.properties
|
76
74
|
@test_results.each do |test|
|
77
|
-
builder.testcase :
|
75
|
+
builder.testcase classname: full_name_for(test), name: test.metadata[:full_description], time: test.metadata[:execution_result][:run_time] do
|
78
76
|
case test.metadata[:execution_result][:status]
|
79
|
-
when
|
80
|
-
builder.failure :
|
77
|
+
when 'failed'
|
78
|
+
builder.failure message: "failed #{test.metadata[:full_description]}", type: 'failed' do
|
81
79
|
builder.cdata! failure_details_for test
|
82
80
|
end
|
83
|
-
when
|
81
|
+
when 'pending' then builder.skipped
|
84
82
|
end
|
85
83
|
end
|
86
84
|
end
|
data/spec/local_execute.rb
CHANGED
@@ -7,21 +7,21 @@ require_relative '../lib/depengine/log/log'
|
|
7
7
|
$log = Log::DeploymentLogger.new
|
8
8
|
$log.writer.level = Log4r::ERROR
|
9
9
|
|
10
|
-
describe
|
10
|
+
describe 'the local executor' do
|
11
11
|
include Processor
|
12
12
|
|
13
|
-
it
|
13
|
+
it 'should execute commands locally' do
|
14
14
|
tmp_dir = Dir.mktmpdir
|
15
15
|
begin
|
16
|
-
local_execute(["touch #{tmp_dir}/dummy1","touch #{tmp_dir}/dummy2","ls -la #{tmp_dir}"])
|
17
|
-
expect(File.file?(File.join(tmp_dir,'dummy1'))).to be_truthy
|
18
|
-
expect(File.file?(File.join(tmp_dir,'dummy2'))).to be_truthy
|
16
|
+
local_execute(["touch #{tmp_dir}/dummy1", "touch #{tmp_dir}/dummy2", "ls -la #{tmp_dir}"])
|
17
|
+
expect(File.file?(File.join(tmp_dir, 'dummy1'))).to be_truthy
|
18
|
+
expect(File.file?(File.join(tmp_dir, 'dummy2'))).to be_truthy
|
19
19
|
ensure
|
20
20
|
FileUtils.remove_entry tmp_dir
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
it
|
25
|
-
expect{local_execute([
|
24
|
+
it 'does stop executing further commands' do
|
25
|
+
expect { local_execute(['false']) }.to raise_error
|
26
26
|
end
|
27
27
|
end
|
data/spec/log_spec.rb
CHANGED
@@ -4,67 +4,66 @@ require_relative '../lib/depengine/log/log'
|
|
4
4
|
require 'stringio'
|
5
5
|
require 'tmpdir'
|
6
6
|
|
7
|
-
describe
|
8
|
-
it
|
7
|
+
describe 'logging' do
|
8
|
+
it 'should log a message to STDOUT' do
|
9
9
|
# redirect STDOUT
|
10
10
|
sio = StringIO.new
|
11
11
|
old_stdout, $stdout = $stdout, sio
|
12
12
|
|
13
13
|
log = Log::DeploymentLogger.new
|
14
14
|
log.writer.level = Log4r::DEBUG
|
15
|
-
log.writer.debug
|
15
|
+
log.writer.debug 'Logger is now setup'
|
16
16
|
|
17
17
|
# restore STDOUT
|
18
18
|
$stdout = old_stdout
|
19
19
|
result = sio.string
|
20
20
|
|
21
|
-
result.should include(
|
21
|
+
result.should include('Logger is now setup')
|
22
22
|
end
|
23
23
|
|
24
|
-
it
|
24
|
+
it 'should log a message to STDOUT with priority WARN' do
|
25
25
|
# redirect STDOUT
|
26
26
|
sio = StringIO.new
|
27
27
|
old_stdout, $stdout = $stdout, sio
|
28
28
|
|
29
29
|
log = Log::DeploymentLogger.new
|
30
30
|
log.writer.level = Log4r::WARN
|
31
|
-
log.writer.warn
|
31
|
+
log.writer.warn 'Logger is now setup'
|
32
32
|
|
33
33
|
# restore STDOUT
|
34
34
|
$stdout = old_stdout
|
35
35
|
result = sio.string
|
36
36
|
|
37
|
-
result.should include(
|
37
|
+
result.should include('Logger is now setup')
|
38
38
|
end
|
39
39
|
|
40
|
-
it
|
40
|
+
it 'should log a message to a logfile' do
|
41
41
|
tmp_dir = Dir.mktmpdir
|
42
42
|
begin
|
43
43
|
log = Log::DeploymentLogger.new
|
44
|
-
log.add_outputter(Log4r::FileOutputter.new('log_warn', :
|
45
|
-
log.writer.info
|
44
|
+
log.add_outputter(Log4r::FileOutputter.new('log_warn', filename: "#{tmp_dir}/log_spec.log", level: Log4r::INFO))
|
45
|
+
log.writer.info 'Logger is now setup'
|
46
46
|
|
47
47
|
File.open("#{tmp_dir}/log_spec.log", 'r') do |line|
|
48
|
-
line.gets.should include(
|
48
|
+
line.gets.should include('Logger is now setup')
|
49
49
|
end
|
50
50
|
ensure
|
51
51
|
FileUtils.rm_rf tmp_dir
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
|
-
it
|
55
|
+
it 'should log a message to a logfile with a level set' do
|
56
56
|
tmp_dir = Dir.mktmpdir
|
57
57
|
begin
|
58
58
|
log = Log::DeploymentLogger.new
|
59
|
-
log.add_outputter(Log4r::FileOutputter.new('log_warn', :
|
60
|
-
log.writer.info
|
61
|
-
log.writer.warn
|
59
|
+
log.add_outputter(Log4r::FileOutputter.new('log_warn', filename: "#{tmp_dir}/log_spec.log"), Log4r::WARN)
|
60
|
+
log.writer.info 'this is an info message'
|
61
|
+
log.writer.warn 'this is a warn message'
|
62
62
|
|
63
|
-
File.open("#{tmp_dir}/log_spec.log", 'r').read.should_not include(
|
64
|
-
File.open("#{tmp_dir}/log_spec.log", 'r').read.should include(
|
63
|
+
File.open("#{tmp_dir}/log_spec.log", 'r').read.should_not include('this is an info message')
|
64
|
+
File.open("#{tmp_dir}/log_spec.log", 'r').read.should include('this is a warn message')
|
65
65
|
ensure
|
66
66
|
FileUtils.rm_rf tmp_dir
|
67
67
|
end
|
68
68
|
end
|
69
69
|
end
|
70
|
-
|
data/spec/properties_spec.rb
CHANGED
@@ -1,27 +1,25 @@
|
|
1
1
|
require_relative '../lib/depengine/processor/properties'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe 'the properties patcher' do
|
4
4
|
|
5
|
-
it
|
6
|
-
test = Processor::Properties.new
|
7
|
-
test.properties_hash = {
|
8
|
-
test.assigner =
|
9
|
-
test.patch(
|
5
|
+
it 'should patch properties in a file by key/value' do
|
6
|
+
test = Processor::Properties.new
|
7
|
+
test.properties_hash = { 'webhost' => 'www.sinnerschrader.com', 'mailhost' => 'mail.google.com' }
|
8
|
+
test.assigner = '='
|
9
|
+
test.patch('spec/properties/source/config.properties', 'spec/properties/target/config.properties')
|
10
10
|
|
11
|
-
|
12
|
-
File.open('spec/properties/target/config.properties').read.should include "webhost=www.sinnerschrader.com"
|
11
|
+
File.open('spec/properties/target/config.properties').read.should include 'webhost=www.sinnerschrader.com'
|
13
12
|
|
14
13
|
FileUtils.rm_rf('spec/properties/target/config.properties')
|
15
14
|
end
|
16
15
|
|
17
|
-
it
|
18
|
-
test = Processor::Properties.new
|
19
|
-
test.properties_hash = {
|
20
|
-
test.substitute(
|
16
|
+
it 'should patch strings in file' do
|
17
|
+
test = Processor::Properties.new
|
18
|
+
test.properties_hash = { 'old_string' => 'new_string', 'even older string' => '' }
|
19
|
+
test.substitute('spec/properties/source/random.rb', 'spec/properties/target/random.rb')
|
21
20
|
|
22
|
-
File.open('spec/properties/target/random.rb').read.should include
|
23
|
-
File.open('spec/properties/target/random.rb').read.should_not include
|
21
|
+
File.open('spec/properties/target/random.rb').read.should include 'new_string'
|
22
|
+
File.open('spec/properties/target/random.rb').read.should_not include 'even older string'
|
24
23
|
FileUtils.rm_rf('spec/properties/target/random.rb')
|
25
24
|
end
|
26
25
|
end
|
27
|
-
|
data/spec/recipe_spec.rb
CHANGED
@@ -1,34 +1,33 @@
|
|
1
1
|
require_relative '../lib/depengine'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe 'a recipe' do
|
4
4
|
|
5
|
-
context
|
6
|
-
it
|
5
|
+
context 'when running' do
|
6
|
+
it 'does create a Deployment.deliver block' do
|
7
7
|
|
8
|
-
Deployment::Methods.set :env,
|
9
|
-
Deployment::Methods.set :version,
|
10
|
-
Deployment::Methods.set :deploy_home,
|
11
|
-
Deployment::Methods.set :module_name,
|
8
|
+
Deployment::Methods.set :env, 'test'
|
9
|
+
Deployment::Methods.set :version, '0.42'
|
10
|
+
Deployment::Methods.set :deploy_home, '.'
|
11
|
+
Deployment::Methods.set :module_name, 'module_name'
|
12
12
|
|
13
|
-
expect{Deployment.deliver {puts
|
13
|
+
expect { Deployment.deliver { puts '.' } }.to raise_error(SystemExit)
|
14
14
|
|
15
15
|
end
|
16
16
|
|
17
|
-
it
|
17
|
+
it 'sets some values with the set method' do
|
18
18
|
Deployment::Methods.set :spec_key, :this_is_set
|
19
19
|
expect($recipe_config[:spec_key]).to be :this_is_set
|
20
20
|
end
|
21
21
|
|
22
22
|
end
|
23
23
|
|
24
|
+
context 'before running' do
|
25
|
+
it 'needs to set a module name' do
|
26
|
+
Deployment::Methods.set :env, 'test'
|
27
|
+
Deployment::Methods.set :version, '0.42'
|
28
|
+
Deployment::Methods.set :deploy_home, '.'
|
24
29
|
|
25
|
-
|
26
|
-
it "needs to set a module name" do
|
27
|
-
Deployment::Methods.set :env, "test"
|
28
|
-
Deployment::Methods.set :version, "0.42"
|
29
|
-
Deployment::Methods.set :deploy_home, "."
|
30
|
-
|
31
|
-
expect{Deployment.deliver {puts "."}}.to raise_error(ArgumentError)
|
30
|
+
expect { Deployment.deliver { puts '.' } }.to raise_error(ArgumentError)
|
32
31
|
end
|
33
32
|
end
|
34
33
|
|