sprinkle 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -339,7 +339,7 @@ describe Sprinkle::Installers::Source do
339
339
 
340
340
  it 'should support zip archives' do
341
341
  @installer.source = 'blah.zip'
342
- @extraction = 'unzip'
342
+ @extraction = 'unzip -o'
343
343
  end
344
344
 
345
345
  after do
@@ -347,25 +347,25 @@ describe Sprinkle::Installers::Source do
347
347
  end
348
348
 
349
349
  end
350
-
350
+
351
351
  describe 'base dir calculation' do
352
-
352
+
353
353
  %w( tar tar.gz tgz tar.bz2 tb2 zip ).each do |archive|
354
-
354
+
355
355
  it "should recognize #{archive} style archives" do
356
356
  @installer.source = "blah.#{archive}"
357
357
  @installer.send(:base_dir).should == 'blah'
358
358
  end
359
-
359
+
360
360
  end
361
-
361
+
362
362
  # def base_dir #:nodoc:
363
363
  # if archive_name.split('/').last =~ /(.*)\.(tar\.gz|tgz|tar\.bz2|tar|tb2)/
364
364
  # return $1
365
365
  # end
366
366
  # raise "Unknown base path for source archive: #{@source}, please update code knowledge"
367
- # end
368
-
367
+ # end
368
+
369
369
  end
370
370
 
371
371
  end
@@ -0,0 +1,49 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe Sprinkle::Installers::Zypper do
4
+
5
+ before do
6
+ @package = mock(Sprinkle::Package, :name => 'package')
7
+ end
8
+
9
+ def create_zypper(*packages, &block)
10
+ Sprinkle::Installers::Zypper.new(@package, *packages, &block)
11
+ end
12
+
13
+ describe 'when created' do
14
+
15
+ it 'should accept a single package to install' do
16
+ @installer = create_zypper 'ruby'
17
+ @installer.packages.should == [ 'ruby' ]
18
+ end
19
+
20
+ it 'should accept an array of packages to install' do
21
+ @installer = create_zypper %w( gcc gdb g++ )
22
+ @installer.packages.should == ['gcc', 'gdb', 'g++']
23
+ end
24
+
25
+ it 'should accept an argument list of packages to install' do
26
+ @installer = create_zypper "gcc", "gdb", "g++"
27
+ @installer.packages.should == ['gcc', 'gdb', 'g++']
28
+ end
29
+ end
30
+
31
+ describe 'during installation' do
32
+
33
+ before do
34
+ @installer = create_zypper 'ruby', 'rubygems' do
35
+ pre :install, 'op1'
36
+ post :install, 'op2'
37
+ end
38
+ @install_commands = @installer.send :install_commands
39
+ end
40
+
41
+ it 'should invoke the zypper installer for all specified packages' do
42
+ @install_commands.should =~ /zypper -n install -l -R ruby rubygems/
43
+ end
44
+
45
+ it 'should automatically insert pre/post commands for the specified package' do
46
+ @installer.send(:install_sequence).should == [ 'op1', 'zypper -n install -l -R ruby rubygems', 'op2' ]
47
+ end
48
+ end
49
+ end
@@ -160,6 +160,14 @@ CODE
160
160
  pkg.installers[0].class.should == Sprinkle::Installers::Source
161
161
  pkg.installers[1].class.should == Sprinkle::Installers::Gem
162
162
  end
163
+
164
+ it 'should optionally accept a runner installer' do
165
+ pkg = package @name do
166
+ runner 'obscure_installer_by_custom_cmd'
167
+ end
168
+ pkg.should respond_to(:runner)
169
+ pkg.installers.first.class.should == Sprinkle::Installers::Runner
170
+ end
163
171
  end
164
172
 
165
173
  describe 'with a source installer' do
@@ -8,35 +8,35 @@ describe Sprinkle::Verify do
8
8
  verify 'moo' do
9
9
  # Check a file exists
10
10
  has_file 'my_file.txt'
11
-
11
+
12
12
  # Check that a file contains a substring
13
13
  file_contains 'my_file.txt', 'A sunny day on the lower east-side'
14
-
14
+
15
15
  # Check a directory exists
16
16
  has_directory 'mydir'
17
-
17
+
18
18
  # Check a symlink exists
19
19
  has_symlink 'mypointer'
20
-
20
+
21
21
  # Check a symlink points to a certain file
22
22
  has_symlink 'mypointer', 'myfile'
23
-
23
+
24
24
  # Check if an executable exists
25
25
  has_executable '/usr/bin/ruby'
26
-
26
+
27
27
  # Check if a global executable exists (in PATH)
28
28
  has_executable 'rails'
29
-
29
+
30
30
  # Check for a process
31
31
  has_process 'httpd'
32
-
32
+
33
33
  # Check that ruby can include files
34
34
  ruby_can_load 'a', 'b', 'c'
35
-
35
+
36
36
  # Check that a gem exists
37
37
  has_gem 'rails'
38
38
  has_gem 'rails', '2.1.0'
39
-
39
+
40
40
  # Check for a certain RPM package
41
41
  has_rpm 'ntp'
42
42
  end
@@ -45,88 +45,87 @@ describe Sprinkle::Verify do
45
45
  @delivery = mock(Sprinkle::Deployment, :process => true)
46
46
  @verification.delivery = @delivery
47
47
  end
48
-
48
+
49
49
  describe 'when created' do
50
50
  it 'should raise error without a block' do
51
51
  lambda { Verify.new(nil, '') }.should raise_error
52
52
  end
53
53
  end
54
-
54
+
55
55
  describe 'with checks' do
56
56
  it 'should do a "test -f" on the has_file check' do
57
57
  @verification.commands.should include('test -f my_file.txt')
58
58
  end
59
-
59
+
60
60
  it 'should do a grep to see if a file contains a text string' do
61
61
  @verification.commands.should include("grep 'A sunny day on the lower east-side' my_file.txt")
62
62
  end
63
-
63
+
64
64
  it 'should do a "test -d" on the has_directory check' do
65
65
  @verification.commands.should include('test -d mydir')
66
66
  end
67
-
67
+
68
68
  it 'should do a "test -L" to check something is a symbolic link' do
69
69
  @verification.commands.should include('test -L mypointer')
70
70
  end
71
-
71
+
72
72
  it 'should do a test equality to check a symlink points to a specific file' do
73
73
  @verification.commands.should include("test 'myfile' = `readlink mypointer`")
74
74
  end
75
-
75
+
76
76
  it 'should do a "test -x" to check for an executable' do
77
77
  @verification.commands.should include("test -x /usr/bin/ruby")
78
78
  end
79
-
79
+
80
80
  it 'should test the "which" command to look for a global executable' do
81
81
  @verification.commands.should include('[ -n "`echo \`which rails\``" ]')
82
82
  end
83
-
83
+
84
84
  it 'should test the process list to find a process' do
85
- @verification.commands.should include("ps aux | grep 'httpd' | grep -v grep")
85
+ @verification.commands.should include("ps -C httpd")
86
86
  end
87
-
87
+
88
88
  it 'should check if ruby can include a, b, c' do
89
89
  @verification.commands.should include("ruby -e \"require 'rubygems';require 'a';require 'b';require 'c'\"")
90
90
  end
91
-
91
+
92
92
  it 'should check that a ruby gem is installed' do
93
- @verification.commands.should include("sudo gem list | grep -e '^rails (.*.*)$'")
94
- @verification.commands.should include("sudo gem list | grep -e '^rails (.*2\\.1\\.0.*)$'")
93
+ @verification.commands.should include("sudo gem list 'rails' --installed --version '2.1.0' > /dev/null")
95
94
  end
96
-
95
+
97
96
  it 'should check that an RPM is installed' do
98
97
  @verification.commands.should include("rpm -qa | grep ntp")
99
98
  end
100
99
  end
101
-
100
+
102
101
  describe 'with configurations' do
103
102
  # Make sure it includes Sprinkle::Configurable
104
103
  it 'should respond to configurable methods' do
105
104
  @verification.should respond_to(:defaults)
106
105
  end
107
-
106
+
108
107
  it 'should default padding option to 4' do
109
108
  @verification.padding.should eql(4)
110
109
  end
111
110
  end
112
-
111
+
113
112
  describe 'with process' do
114
113
  it 'should raise an error when no delivery mechanism is set' do
115
114
  @verification.instance_variable_set(:@delivery, nil)
116
115
  lambda { @verification.process([]) }.should raise_error
117
116
  end
118
-
117
+
119
118
  describe 'when not testing' do
120
119
  before do
121
120
  # To be explicit
122
121
  Sprinkle::OPTIONS[:testing] = false
123
122
  end
124
-
123
+
125
124
  it 'should call process on the delivery with the correct parameters' do
126
125
  @delivery.should_receive(:process).with(@name, @verification.commands, [:app], true).once.and_return(true)
127
126
  @verification.process([:app])
128
127
  end
129
-
128
+
130
129
  it 'should raise Sprinkle::VerificationFailed exception when commands fail' do
131
130
  @delivery.should_receive(:process).once.and_return(false)
132
131
  lambda { @verification.process([:app]) }.should raise_error(Sprinkle::VerificationFailed) do |error|
@@ -135,13 +134,13 @@ describe Sprinkle::Verify do
135
134
  end
136
135
  end
137
136
  end
138
-
137
+
139
138
  describe 'when testing' do
140
139
  before do
141
140
  Sprinkle::OPTIONS[:testing] = true
142
141
  @logger = mock(ActiveSupport::BufferedLogger, :debug => true, :debug? => true)
143
142
  end
144
-
143
+
145
144
  it 'should not call process on the delivery' do
146
145
  @delivery.should_not_receive(:process)
147
146
  end
@@ -149,26 +148,26 @@ describe Sprinkle::Verify do
149
148
  it 'should print the install sequence to the console' do
150
149
  @verification.should_receive(:logger).twice.and_return(@logger)
151
150
  end
152
-
151
+
153
152
  after do
154
153
  @verification.process([:app])
155
154
  Sprinkle::OPTIONS[:testing] = false
156
155
  end
157
156
  end
158
157
  end
159
-
158
+
160
159
  describe 'with registering new verification modules' do
161
160
  module MyModule
162
161
  def rawr; end
163
162
  end
164
-
163
+
165
164
  it 'should not respond to rawr initially' do
166
165
  @verification.should_not respond_to(:rawr)
167
166
  end
168
-
167
+
169
168
  it 'should respond to rawr after registering the module' do
170
169
  Sprinkle::Verify.register(MyModule)
171
170
  @verification.should respond_to(:rawr)
172
171
  end
173
172
  end
174
- end
173
+ end
metadata CHANGED
@@ -1,7 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sprinkle
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ hash: 23
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 3
9
+ - 2
10
+ version: 0.3.2
5
11
  platform: ruby
6
12
  authors:
7
13
  - Marcus Crafter
@@ -9,49 +15,73 @@ autorequire:
9
15
  bindir: bin
10
16
  cert_chain: []
11
17
 
12
- date: 2009-12-13 00:00:00 +13:00
18
+ date: 2010-12-11 00:00:00 +11:00
13
19
  default_executable: sprinkle
14
20
  dependencies:
15
21
  - !ruby/object:Gem::Dependency
16
22
  name: rspec
17
- type: :development
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
20
26
  requirements:
21
27
  - - ">="
22
28
  - !ruby/object:Gem::Version
29
+ hash: 13
30
+ segments:
31
+ - 1
32
+ - 2
33
+ - 9
23
34
  version: 1.2.9
24
- version:
35
+ type: :development
36
+ version_requirements: *id001
25
37
  - !ruby/object:Gem::Dependency
26
38
  name: activesupport
27
- type: :runtime
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
30
42
  requirements:
31
43
  - - ">="
32
44
  - !ruby/object:Gem::Version
45
+ hash: 11
46
+ segments:
47
+ - 2
48
+ - 0
49
+ - 2
33
50
  version: 2.0.2
34
- version:
51
+ type: :runtime
52
+ version_requirements: *id002
35
53
  - !ruby/object:Gem::Dependency
36
54
  name: highline
37
- type: :runtime
38
- version_requirement:
39
- version_requirements: !ruby/object:Gem::Requirement
55
+ prerelease: false
56
+ requirement: &id003 !ruby/object:Gem::Requirement
57
+ none: false
40
58
  requirements:
41
59
  - - ">="
42
60
  - !ruby/object:Gem::Version
61
+ hash: 7
62
+ segments:
63
+ - 1
64
+ - 4
65
+ - 0
43
66
  version: 1.4.0
44
- version:
67
+ type: :runtime
68
+ version_requirements: *id003
45
69
  - !ruby/object:Gem::Dependency
46
70
  name: capistrano
47
- type: :runtime
48
- version_requirement:
49
- version_requirements: !ruby/object:Gem::Requirement
71
+ prerelease: false
72
+ requirement: &id004 !ruby/object:Gem::Requirement
73
+ none: false
50
74
  requirements:
51
75
  - - ">="
52
76
  - !ruby/object:Gem::Version
77
+ hash: 17
78
+ segments:
79
+ - 2
80
+ - 5
81
+ - 5
53
82
  version: 2.5.5
54
- version:
83
+ type: :runtime
84
+ version_requirements: *id004
55
85
  description: Ruby DSL based software provisioning tool
56
86
  email: crafterm@redartisan.com
57
87
  executables:
@@ -110,6 +140,7 @@ files:
110
140
  - lib/sprinkle/installers/freebsd_pkg.rb
111
141
  - lib/sprinkle/installers/freebsd_portinstall.rb
112
142
  - lib/sprinkle/installers/gem.rb
143
+ - lib/sprinkle/installers/install_package.rb
113
144
  - lib/sprinkle/installers/installer.rb
114
145
  - lib/sprinkle/installers/mac_port.rb
115
146
  - lib/sprinkle/installers/noop.rb
@@ -117,16 +148,23 @@ files:
117
148
  - lib/sprinkle/installers/opensolaris_pkg.rb
118
149
  - lib/sprinkle/installers/push_text.rb
119
150
  - lib/sprinkle/installers/rake.rb
151
+ - lib/sprinkle/installers/replace_text.rb
120
152
  - lib/sprinkle/installers/rpm.rb
153
+ - lib/sprinkle/installers/runner.rb
154
+ - lib/sprinkle/installers/smart.rb
121
155
  - lib/sprinkle/installers/source.rb
122
156
  - lib/sprinkle/installers/transfer.rb
157
+ - lib/sprinkle/installers/user.rb
123
158
  - lib/sprinkle/installers/yum.rb
159
+ - lib/sprinkle/installers/zypper.rb
124
160
  - lib/sprinkle/package.rb
125
161
  - lib/sprinkle/policy.rb
126
162
  - lib/sprinkle/script.rb
163
+ - lib/sprinkle/verifiers/apt.rb
127
164
  - lib/sprinkle/verifiers/directory.rb
128
165
  - lib/sprinkle/verifiers/executable.rb
129
166
  - lib/sprinkle/verifiers/file.rb
167
+ - lib/sprinkle/verifiers/package.rb
130
168
  - lib/sprinkle/verifiers/process.rb
131
169
  - lib/sprinkle/verifiers/rpm.rb
132
170
  - lib/sprinkle/verifiers/ruby.rb
@@ -155,16 +193,20 @@ files:
155
193
  - spec/sprinkle/installers/opensolaris_pkg_spec.rb
156
194
  - spec/sprinkle/installers/push_text_spec.rb
157
195
  - spec/sprinkle/installers/rake_spec.rb
196
+ - spec/sprinkle/installers/replace_text_spec.rb
158
197
  - spec/sprinkle/installers/rpm_spec.rb
198
+ - spec/sprinkle/installers/runner_spec.rb
159
199
  - spec/sprinkle/installers/source_spec.rb
160
200
  - spec/sprinkle/installers/transfer_spec.rb
161
201
  - spec/sprinkle/installers/yum_spec.rb
202
+ - spec/sprinkle/installers/zypper_spec.rb
162
203
  - spec/sprinkle/package_spec.rb
163
204
  - spec/sprinkle/policy_spec.rb
164
205
  - spec/sprinkle/script_spec.rb
165
206
  - spec/sprinkle/sprinkle_spec.rb
166
207
  - spec/sprinkle/verify_spec.rb
167
208
  - TODO
209
+ - spec/sprinkle/sequence_spec.rb
168
210
  has_rdoc: true
169
211
  homepage: http://github.com/crafterm/sprinkle
170
212
  licenses: []
@@ -175,21 +217,27 @@ rdoc_options:
175
217
  require_paths:
176
218
  - lib
177
219
  required_ruby_version: !ruby/object:Gem::Requirement
220
+ none: false
178
221
  requirements:
179
222
  - - ">="
180
223
  - !ruby/object:Gem::Version
224
+ hash: 3
225
+ segments:
226
+ - 0
181
227
  version: "0"
182
- version:
183
228
  required_rubygems_version: !ruby/object:Gem::Requirement
229
+ none: false
184
230
  requirements:
185
231
  - - ">="
186
232
  - !ruby/object:Gem::Version
233
+ hash: 3
234
+ segments:
235
+ - 0
187
236
  version: "0"
188
- version:
189
237
  requirements: []
190
238
 
191
239
  rubyforge_project: sprinkle
192
- rubygems_version: 1.3.5
240
+ rubygems_version: 1.3.7
193
241
  signing_key:
194
242
  specification_version: 3
195
243
  summary: Ruby DSL based software provisioning tool
@@ -213,10 +261,13 @@ test_files:
213
261
  - spec/sprinkle/installers/opensolaris_pkg_spec.rb
214
262
  - spec/sprinkle/installers/push_text_spec.rb
215
263
  - spec/sprinkle/installers/rake_spec.rb
264
+ - spec/sprinkle/installers/replace_text_spec.rb
216
265
  - spec/sprinkle/installers/rpm_spec.rb
266
+ - spec/sprinkle/installers/runner_spec.rb
217
267
  - spec/sprinkle/installers/source_spec.rb
218
268
  - spec/sprinkle/installers/transfer_spec.rb
219
269
  - spec/sprinkle/installers/yum_spec.rb
270
+ - spec/sprinkle/installers/zypper_spec.rb
220
271
  - spec/sprinkle/package_spec.rb
221
272
  - spec/sprinkle/policy_spec.rb
222
273
  - spec/sprinkle/script_spec.rb