mitchellh-sprinkle 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CREDITS +16 -0
- data/History.txt +4 -0
- data/MIT-LICENSE +20 -0
- data/Manifest.txt +68 -0
- data/README.txt +224 -0
- data/Rakefile +4 -0
- data/bin/sprinkle +86 -0
- data/config/hoe.rb +70 -0
- data/config/requirements.rb +17 -0
- data/examples/merb/deploy.rb +5 -0
- data/examples/rails/README +15 -0
- data/examples/rails/deploy.rb +2 -0
- data/examples/rails/packages/database.rb +9 -0
- data/examples/rails/packages/essential.rb +6 -0
- data/examples/rails/packages/rails.rb +28 -0
- data/examples/rails/packages/search.rb +11 -0
- data/examples/rails/packages/server.rb +28 -0
- data/examples/rails/rails.rb +71 -0
- data/examples/sprinkle/sprinkle.rb +38 -0
- data/lib/sprinkle/actors/actors.rb +17 -0
- data/lib/sprinkle/actors/capistrano.rb +117 -0
- data/lib/sprinkle/actors/vlad.rb +65 -0
- data/lib/sprinkle/configurable.rb +27 -0
- data/lib/sprinkle/deployment.rb +73 -0
- data/lib/sprinkle/extensions/arbitrary_options.rb +10 -0
- data/lib/sprinkle/extensions/array.rb +5 -0
- data/lib/sprinkle/extensions/blank_slate.rb +5 -0
- data/lib/sprinkle/extensions/dsl_accessor.rb +15 -0
- data/lib/sprinkle/extensions/string.rb +10 -0
- data/lib/sprinkle/extensions/symbol.rb +7 -0
- data/lib/sprinkle/installers/apt.rb +51 -0
- data/lib/sprinkle/installers/gem.rb +61 -0
- data/lib/sprinkle/installers/installer.rb +120 -0
- data/lib/sprinkle/installers/rake.rb +30 -0
- data/lib/sprinkle/installers/rpm.rb +37 -0
- data/lib/sprinkle/installers/source.rb +179 -0
- data/lib/sprinkle/package.rb +127 -0
- data/lib/sprinkle/policy.rb +85 -0
- data/lib/sprinkle/script.rb +13 -0
- data/lib/sprinkle/verifiers/directory.rb +11 -0
- data/lib/sprinkle/verifiers/executable.rb +17 -0
- data/lib/sprinkle/verifiers/file.rb +11 -0
- data/lib/sprinkle/verifiers/symlink.rb +15 -0
- data/lib/sprinkle/verify.rb +55 -0
- data/lib/sprinkle/version.rb +9 -0
- data/lib/sprinkle.rb +32 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +17 -0
- data/spec/sprinkle/actors/capistrano_spec.rb +170 -0
- data/spec/sprinkle/configurable_spec.rb +46 -0
- data/spec/sprinkle/deployment_spec.rb +80 -0
- data/spec/sprinkle/extensions/array_spec.rb +19 -0
- data/spec/sprinkle/extensions/string_spec.rb +21 -0
- data/spec/sprinkle/installers/apt_spec.rb +74 -0
- data/spec/sprinkle/installers/gem_spec.rb +75 -0
- data/spec/sprinkle/installers/installer_spec.rb +151 -0
- data/spec/sprinkle/installers/rpm_spec.rb +50 -0
- data/spec/sprinkle/installers/source_spec.rb +331 -0
- data/spec/sprinkle/package_spec.rb +422 -0
- data/spec/sprinkle/policy_spec.rb +126 -0
- data/spec/sprinkle/script_spec.rb +51 -0
- data/spec/sprinkle/sprinkle_spec.rb +25 -0
- data/spec/sprinkle/verify_spec.rb +137 -0
- data/sprinkle.gemspec +43 -0
- data/tasks/deployment.rake +34 -0
- data/tasks/environment.rake +7 -0
- data/tasks/rspec.rake +21 -0
- metadata +160 -0
@@ -0,0 +1,55 @@
|
|
1
|
+
module Sprinkle
|
2
|
+
class Verify
|
3
|
+
include Sprinkle::Configurable
|
4
|
+
attr_accessor :package, :description, :commands
|
5
|
+
|
6
|
+
class <<self
|
7
|
+
# Register a verification module
|
8
|
+
def register(new_module)
|
9
|
+
class_eval { include new_module }
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def initialize(package, description = '', &block)
|
14
|
+
raise 'Verify requires a block.' unless block
|
15
|
+
|
16
|
+
@package = package
|
17
|
+
@description = description
|
18
|
+
@commands = []
|
19
|
+
@options ||= {}
|
20
|
+
@options[:padding] = 4
|
21
|
+
|
22
|
+
self.instance_eval(&block)
|
23
|
+
end
|
24
|
+
|
25
|
+
def process(roles, pre = false)
|
26
|
+
assert_delivery
|
27
|
+
|
28
|
+
description = @description.empty? ? @package.name : @description
|
29
|
+
|
30
|
+
if logger.debug?
|
31
|
+
logger.debug "#{@package.name}#{description} verification sequence: #{@commands.join('; ')} for roles: #{roles}\n"
|
32
|
+
end
|
33
|
+
|
34
|
+
unless Sprinkle::OPTIONS[:testing]
|
35
|
+
logger.info "#{" " * @options[:padding]}--> Verifying #{description}..."
|
36
|
+
|
37
|
+
unless @delivery.process(@package.name, @commands, roles, true)
|
38
|
+
# Verification failed, halt sprinkling gracefully.
|
39
|
+
raise Sprinkle::VerificationFailed.new(@package, description)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
class VerificationFailed < Exception
|
46
|
+
attr_accessor :package, :description
|
47
|
+
|
48
|
+
def initialize(package, description)
|
49
|
+
super("Verifying #{package.name}#{description} failed.")
|
50
|
+
|
51
|
+
@package = package
|
52
|
+
@description = description
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
data/lib/sprinkle.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'active_support'
|
3
|
+
|
4
|
+
# Use active supports auto load mechanism
|
5
|
+
Dependencies.load_paths << File.dirname(__FILE__)
|
6
|
+
|
7
|
+
# Configure active support to log auto-loading of dependencies
|
8
|
+
#Dependencies::RAILS_DEFAULT_LOGGER = Logger.new($stdout)
|
9
|
+
#Dependencies.log_activity = true
|
10
|
+
|
11
|
+
# Load up extensions to existing classes
|
12
|
+
Dir[File.dirname(__FILE__) + '/sprinkle/extensions/*.rb'].each { |e| require e }
|
13
|
+
# Load up the verifiers so they can register themselves
|
14
|
+
Dir[File.dirname(__FILE__) + '/sprinkle/verifiers/*.rb'].each { |e| require e }
|
15
|
+
|
16
|
+
# Configuration options
|
17
|
+
module Sprinkle
|
18
|
+
OPTIONS = { :testing => false, :verbose => false, :force => false }
|
19
|
+
end
|
20
|
+
|
21
|
+
# Object is extended to give the package, policy, and deployment methods. To
|
22
|
+
# read about each method, see the corresponding module which is included.
|
23
|
+
#--
|
24
|
+
# Define a logging target and understand packages, policies and deployment DSL
|
25
|
+
#++
|
26
|
+
class Object
|
27
|
+
include Sprinkle::Package, Sprinkle::Policy, Sprinkle::Deployment
|
28
|
+
|
29
|
+
def logger # :nodoc:
|
30
|
+
@@__log__ ||= ActiveSupport::BufferedLogger.new($stdout, ActiveSupport::BufferedLogger::Severity::INFO)
|
31
|
+
end
|
32
|
+
end
|
data/script/destroy
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/destroy'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
+
RubiGen::Scripts::Destroy.new.run(ARGV)
|
data/script/generate
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/generate'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
+
RubiGen::Scripts::Generate.new.run(ARGV)
|
data/spec/spec.opts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--colour
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
begin
|
2
|
+
require 'spec'
|
3
|
+
rescue LoadError
|
4
|
+
require 'rubygems'
|
5
|
+
gem 'rspec'
|
6
|
+
require 'spec'
|
7
|
+
end
|
8
|
+
|
9
|
+
$:.unshift(File.dirname(__FILE__) + '/../lib')
|
10
|
+
require 'sprinkle'
|
11
|
+
|
12
|
+
module Kernel
|
13
|
+
def logger
|
14
|
+
@@__log_file__ ||= StringIO.new
|
15
|
+
@@__log__ = ActiveSupport::BufferedLogger.new @@__log_file__
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,170 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
describe Sprinkle::Actors::Capistrano do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@recipes = 'deploy'
|
7
|
+
@cap = ::Capistrano::Configuration.new
|
8
|
+
::Capistrano::Configuration.stub!(:new).and_return(@cap)
|
9
|
+
@cap.stub!(:load).and_return
|
10
|
+
end
|
11
|
+
|
12
|
+
def create_cap(&block)
|
13
|
+
Sprinkle::Actors::Capistrano.new &block
|
14
|
+
end
|
15
|
+
|
16
|
+
describe 'when created' do
|
17
|
+
|
18
|
+
it 'should create a new capistrano object' do
|
19
|
+
::Capistrano::Configuration.should_receive(:new).and_return(@cap)
|
20
|
+
create_cap
|
21
|
+
end
|
22
|
+
|
23
|
+
describe 'when verbose' do
|
24
|
+
|
25
|
+
before do
|
26
|
+
Sprinkle::OPTIONS[:verbose] = true
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should set verbose logging on the capistrano object' do
|
30
|
+
@cap = create_cap
|
31
|
+
@cap.config.logger.level.should == ::Capistrano::Logger::INFO
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
describe 'when not verbose' do
|
37
|
+
|
38
|
+
before do
|
39
|
+
Sprinkle::OPTIONS[:verbose] = false
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'should set quiet logging on the capistrano object' do
|
43
|
+
@cap = create_cap
|
44
|
+
@cap.config.logger.level.should == ::Capistrano::Logger::IMPORTANT
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
describe 'with a block' do
|
50
|
+
|
51
|
+
before do
|
52
|
+
@actor = create_cap do
|
53
|
+
recipes 'cool gear' # default is deploy
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'should evaluate the block against the actor instance' do
|
58
|
+
@actor.loaded_recipes.should include('cool gear')
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
describe 'without a block' do
|
64
|
+
|
65
|
+
it 'should automatically load the default capistrano configuration' do
|
66
|
+
@cap.should_receive(:load).with('deploy').and_return
|
67
|
+
end
|
68
|
+
|
69
|
+
after do
|
70
|
+
@actor = create_cap
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
describe 'recipes' do
|
78
|
+
|
79
|
+
it 'should add the recipe location to an internal store' do
|
80
|
+
@cap = create_cap do
|
81
|
+
recipes 'deploy'
|
82
|
+
end
|
83
|
+
@cap.loaded_recipes.should == [ @recipes ]
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'should load the given recipe' do
|
87
|
+
@cap.should_receive(:load).with(@recipes).and_return
|
88
|
+
create_cap
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
|
93
|
+
describe 'processing commands' do
|
94
|
+
|
95
|
+
before do
|
96
|
+
@commands = %w( op1 op2 )
|
97
|
+
@roles = %w( app )
|
98
|
+
@name = 'name'
|
99
|
+
|
100
|
+
@cap = create_cap do; recipes 'deploy'; end
|
101
|
+
@cap.stub!(:run).and_return
|
102
|
+
|
103
|
+
@testing_errors = false
|
104
|
+
end
|
105
|
+
|
106
|
+
it 'should dynamically create a capistrano task containing the commands' do
|
107
|
+
@cap.config.should_receive(:task).and_return
|
108
|
+
end
|
109
|
+
|
110
|
+
it 'should invoke capistrano task after creation' do
|
111
|
+
@cap.should_receive(:run).with(@name).and_return
|
112
|
+
end
|
113
|
+
|
114
|
+
it 'should raise capistrano errors when suppressing parameter is not set' do
|
115
|
+
@testing_errors = true
|
116
|
+
|
117
|
+
@cap.should_receive(:run).and_raise(::Capistrano::CommandError)
|
118
|
+
lambda { @cap.process @name, @commands, @roles }.should raise_error(::Capistrano::CommandError)
|
119
|
+
end
|
120
|
+
|
121
|
+
it 'should not raise errors and instead return false when suppressing parameter is set' do
|
122
|
+
@testing_errors = true
|
123
|
+
|
124
|
+
@cap.should_receive(:run).and_raise(::Capistrano::CommandError)
|
125
|
+
|
126
|
+
value = nil
|
127
|
+
lambda { value = @cap.process(@name, @commands, @roles, true) }.should_not raise_error(::Capistrano::CommandError)
|
128
|
+
|
129
|
+
value.should_not be
|
130
|
+
end
|
131
|
+
|
132
|
+
after do
|
133
|
+
@cap.process @name, @commands, @roles unless @testing_errors
|
134
|
+
end
|
135
|
+
|
136
|
+
end
|
137
|
+
|
138
|
+
describe 'generated task' do
|
139
|
+
|
140
|
+
before do
|
141
|
+
@commands = %w( op1 op2 )
|
142
|
+
@roles = %w( app )
|
143
|
+
@name = 'name'
|
144
|
+
|
145
|
+
@cap = create_cap do; recipes 'deploy'; end
|
146
|
+
@cap.config.stub!(:fetch).and_return(:sudo)
|
147
|
+
@cap.config.stub!(:invoke_command).and_return
|
148
|
+
end
|
149
|
+
|
150
|
+
it 'should use sudo to invoke commands when so configured' do
|
151
|
+
@cap.config.should_receive(:fetch).with(:run_method, :sudo).and_return(:sudo)
|
152
|
+
end
|
153
|
+
|
154
|
+
it 'should run the supplied commands' do
|
155
|
+
@cap.config.should_receive(:invoke_command).with('op1', :via => :sudo).ordered.and_return
|
156
|
+
@cap.config.should_receive(:invoke_command).with('op2', :via => :sudo).ordered.and_return
|
157
|
+
end
|
158
|
+
|
159
|
+
it 'should be applicable for the supplied roles' do
|
160
|
+
@cap.stub!(:run).and_return
|
161
|
+
@cap.config.should_receive(:task).with(:install_name, :roles => @roles).and_return
|
162
|
+
end
|
163
|
+
|
164
|
+
after do
|
165
|
+
@cap.process @name, @commands, @roles
|
166
|
+
end
|
167
|
+
|
168
|
+
end
|
169
|
+
|
170
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe Sprinkle::Configurable do
|
4
|
+
module MyPrefix
|
5
|
+
class Configurable
|
6
|
+
include Sprinkle::Configurable
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
before do
|
11
|
+
@configurable = MyPrefix::Configurable.new
|
12
|
+
@default = Proc.new { }
|
13
|
+
@defaults = { :configurable => @default }
|
14
|
+
@deployment.stub!(:defaults).and_return(@defaults)
|
15
|
+
@deployment.stub!(:style)
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should be configurable via external defaults' do
|
19
|
+
@configurable.should respond_to(:defaults)
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should select the defaults for the particular concrete installer class' do
|
23
|
+
@deployment.should_receive(:defaults).and_return(@defaults)
|
24
|
+
@defaults.should_receive(:[]).with(:configurable).and_return(@default)
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should configure the installer delivery mechansim' do
|
28
|
+
@configurable.should_receive(:instance_eval)
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should maintain an options hash set arbitrarily via method missing' do
|
32
|
+
@configurable.instance_eval do
|
33
|
+
hsv 'gts'
|
34
|
+
end
|
35
|
+
@configurable.hsv.should == 'gts'
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'should allow the delivery instance variable to be accessed' do
|
39
|
+
@configurable.delivery = "string"
|
40
|
+
@configurable.instance_variable_get(:@delivery).should eql("string")
|
41
|
+
end
|
42
|
+
|
43
|
+
after do
|
44
|
+
@configurable.defaults(@deployment)
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe Sprinkle::Deployment do
|
4
|
+
include Sprinkle::Deployment
|
5
|
+
|
6
|
+
def create_deployment(&block)
|
7
|
+
deployment do
|
8
|
+
delivery :capistrano, &block
|
9
|
+
|
10
|
+
source do
|
11
|
+
prefix '/usr/local'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe 'when created' do
|
17
|
+
|
18
|
+
it 'should be invalid without a block descriptor' do
|
19
|
+
lambda { deployment }.should raise_error
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should be invalid without a delivery method' do
|
23
|
+
lambda { @deployment = deployment do; end }.should raise_error
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should optionally accept installer defaults' do
|
27
|
+
@deployment = create_deployment
|
28
|
+
@deployment.should respond_to(:source)
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should provide installer defaults as a proc when requested' do
|
32
|
+
@deployment = create_deployment
|
33
|
+
@deployment.defaults[:source].class.should == Proc
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
describe 'delivery specification' do
|
39
|
+
|
40
|
+
before do
|
41
|
+
@actor = mock(Sprinkle::Actors::Capistrano)
|
42
|
+
Sprinkle::Actors::Capistrano.stub!(:new).and_return(@actor)
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'should automatically instantiate the delivery type' do
|
46
|
+
@deployment = create_deployment
|
47
|
+
@deployment.style.should == @actor
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'should optionally accept a block to pass to the actor' do
|
51
|
+
lambda { @deployment = create_deployment }.should_not raise_error
|
52
|
+
end
|
53
|
+
|
54
|
+
describe 'with a block' do
|
55
|
+
|
56
|
+
it 'should pass the block to the actor for configuration' do
|
57
|
+
@deployment = create_deployment do; recipes 'deploy'; end
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe 'when processing policies' do
|
64
|
+
|
65
|
+
before do
|
66
|
+
@policy = mock(Policy, :process => true)
|
67
|
+
POLICIES = [ @policy ]
|
68
|
+
@deployment = create_deployment
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'should apply all policies, passing itself as the deployment context' do
|
72
|
+
@policy.should_receive(:process).with(@deployment).and_return
|
73
|
+
end
|
74
|
+
|
75
|
+
after do
|
76
|
+
@deployment.process
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
describe Array, 'task name conversions' do
|
4
|
+
|
5
|
+
it 'should be able to deliver a task name' do
|
6
|
+
['build_essential'].to_task_name.should == 'build_essential'
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should join multiple elements together with a _ char' do
|
10
|
+
['gdb', 'gcc', 'g++'].to_task_name.should == 'gdb_gcc_g++'
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should use the task name of the underlying array element' do
|
14
|
+
string = 'build-essential'
|
15
|
+
string.should_receive(:to_task_name).and_return('build_essential')
|
16
|
+
[string].to_task_name.should == 'build_essential'
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
describe String, 'task name conversions' do
|
4
|
+
|
5
|
+
it 'should be able to deliver a task name' do
|
6
|
+
'build_essential'.to_task_name.should == 'build_essential'
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should convert all - chars to _ in the task name' do
|
10
|
+
'build-essential'.to_task_name.should == 'build_essential'
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should convert multiple - chars to _ chars in the task name' do
|
14
|
+
'build--essential'.to_task_name.should == 'build__essential'
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should lowercase the task name' do
|
18
|
+
'BUILD-ESSENTIAL'.to_task_name.should == 'build_essential'
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
describe Sprinkle::Installers::Apt do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@package = mock(Sprinkle::Package, :name => 'package')
|
7
|
+
end
|
8
|
+
|
9
|
+
def create_apt(*debs, &block)
|
10
|
+
Sprinkle::Installers::Apt.new(@package, *debs, &block)
|
11
|
+
end
|
12
|
+
|
13
|
+
describe 'when created' do
|
14
|
+
|
15
|
+
it 'should accept a single package to install' do
|
16
|
+
@installer = create_apt 'ruby'
|
17
|
+
@installer.packages.should == [ 'ruby' ]
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should accept an array of packages to install' do
|
21
|
+
@installer = create_apt %w( gcc gdb g++ )
|
22
|
+
@installer.packages.should == ['gcc', 'gdb', 'g++']
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
describe 'when created for dependencies only install' do
|
28
|
+
|
29
|
+
it 'should remove options from packages list' do
|
30
|
+
@installer = create_apt 'ruby', :dependencies_only => true
|
31
|
+
@installer.packages.should == [ 'ruby' ]
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
describe 'during installation' do
|
37
|
+
|
38
|
+
before do
|
39
|
+
@installer = create_apt 'ruby' do
|
40
|
+
pre :install, 'op1'
|
41
|
+
post :install, 'op2'
|
42
|
+
end
|
43
|
+
@install_commands = @installer.send :install_commands
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'should invoke the apt installer for all specified packages' do
|
47
|
+
@install_commands.should =~ /apt-get -qyu install ruby/
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'should specify a non interactive mode to the apt installer' do
|
51
|
+
@install_commands.should =~ /DEBIAN_FRONTEND=noninteractive/
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'should automatically insert pre/post commands for the specified package' do
|
55
|
+
@installer.send(:install_sequence).should == [ 'op1', %(DEBCONF_TERSE='yes' DEBIAN_PRIORITY='critical' DEBIAN_FRONTEND=noninteractive apt-get -qyu install ruby), 'op2' ]
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'should install a specific version if defined'
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
describe 'during dependencies only installation' do
|
63
|
+
|
64
|
+
before do
|
65
|
+
@installer = create_apt 'ruby', :dependencies_only => true
|
66
|
+
@install_commands = @installer.send :install_commands
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'should invoke the apt installer with build-dep command for all specified packages' do
|
70
|
+
@install_commands.should =~ /apt-get -qyu build-dep ruby/
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
describe Sprinkle::Installers::Gem do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@gem = 'rails'
|
7
|
+
@version = '2.0.2'
|
8
|
+
@options = { :source => 'http://gems.github.com/', :repository => '/tmp/gems' }
|
9
|
+
end
|
10
|
+
|
11
|
+
def create_gem(gem, version = nil, options = {}, &block)
|
12
|
+
@package = mock(Sprinkle::Package, :name => gem, :version => version, :source => nil, :repository => nil)
|
13
|
+
Sprinkle::Installers::Gem.new(@package, gem, options, &block)
|
14
|
+
end
|
15
|
+
|
16
|
+
describe 'when created' do
|
17
|
+
|
18
|
+
before do
|
19
|
+
@installer = create_gem @gem, @version, @options
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should accept a single package to install' do
|
23
|
+
@installer.gem.should == @gem
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should optionally store a version of the gem to install' do
|
27
|
+
@installer.version.should == '2.0.2'
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should optionally store a source location of the gem to install' do
|
31
|
+
@installer.source.should == 'http://gems.github.com/'
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should optionally store the repository location where gems are to be installed' do
|
35
|
+
@installer.repository.should == @options[:repository]
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
describe 'during installation' do
|
41
|
+
|
42
|
+
describe 'without a version' do
|
43
|
+
|
44
|
+
before do
|
45
|
+
@installer = create_gem @gem do
|
46
|
+
pre :install, 'op1'
|
47
|
+
post :install, 'op2'
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'should invoke the gem installer for the specified package' do
|
52
|
+
@installer.send(:install_commands).should == "gem install #{@gem}"
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'should automatically insert pre/post commands for the specified package' do
|
56
|
+
@installer.send(:install_sequence).should == [ 'op1', "gem install #{@gem}", 'op2' ]
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
describe 'with a specific version' do
|
62
|
+
|
63
|
+
before do
|
64
|
+
@installer = create_gem @gem, @version
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'should install a specific version if defined' do
|
68
|
+
@installer.send(:install_commands).should == "gem install #{@gem} --version '#{@version}'"
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|