crafterm-sprinkle 0.2.0 → 0.2.1

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 CHANGED
@@ -17,3 +17,5 @@ Mitchell Hashimoto (http://mitchellhashimoto.com)
17
17
  Ari Lerner (http://www.citrusbyte.com)
18
18
  Jorgen Orehøj Erichsen (http://blog.erichsen.net)
19
19
  Joshua Sierles (http://diluvia.net)
20
+ Julian Russell (http://github.com/plusplus)
21
+ Dave (Gassto) (http://github.com/gassto)
data/Manifest.txt CHANGED
@@ -49,6 +49,11 @@ lib/sprinkle/installers/rake.rb
49
49
  lib/sprinkle/installers/rpm.rb
50
50
  lib/sprinkle/installers/source.rb
51
51
  lib/sprinkle/installers/yum.rb
52
+ lib/sprinkle/installers/freebsd_pkg.rb
53
+ lib/sprinkle/installers/openbsd_pkg.rb
54
+ lib/sprinkle/installers/opensolaris_pkg.rb
55
+ lib/sprinkle/installers/bsd_port.rb
56
+ lib/sprinkle/installers/mac_port.rb
52
57
  lib/sprinkle/package.rb
53
58
  lib/sprinkle/policy.rb
54
59
  lib/sprinkle/script.rb
@@ -76,6 +81,10 @@ spec/sprinkle/installers/installer_spec.rb
76
81
  spec/sprinkle/installers/rpm_spec.rb
77
82
  spec/sprinkle/installers/yum_spec.rb
78
83
  spec/sprinkle/installers/source_spec.rb
84
+ spec/sprinkle/installers/openbsd_pkg_spec.rb
85
+ spec/sprinkle/installers/freebsd_pkg_spec.rb
86
+ spec/sprinkle/installers/bsd_port_spec.rb
87
+ spec/sprinkle/installers/mac_port_spec.rb
79
88
  spec/sprinkle/package_spec.rb
80
89
  spec/sprinkle/policy_spec.rb
81
90
  spec/sprinkle/script_spec.rb
data/README.txt CHANGED
@@ -2,6 +2,9 @@
2
2
 
3
3
  http://redartisan.com/2008/5/27/sprinkle-intro
4
4
  http://github.com/crafterm/sprinkle
5
+ http://github.com/benschwarz/passenger-stack
6
+ http://www.vimeo.com/2888665
7
+ http://redartisan.lighthouseapp.com/projects/25275-sprinkle/tickets
5
8
 
6
9
  == DESCRIPTION:
7
10
 
@@ -205,7 +208,7 @@ and Git (via source with dependencies from APT):
205
208
 
206
209
  end
207
210
 
208
- Please see the examples directory for more complete examples of Sprinkle deployment scripts.
211
+ Please see the examples directory for more complete examples of Sprinkle deployment scripts, and also the Passenger Stack github page and video by Ben Schwarz (http://github.com/benschwarz/passenger-stack and http://www.vimeo.com/2888665 respectively).
209
212
 
210
213
  Sprinkle is a work in progress and I'm excited to hear if anyone finds it useful - please feel free to
211
214
  comment, ask any questions, or send in any ideas, patches, bugs. All most welcome.
data/config/hoe.rb CHANGED
@@ -58,7 +58,7 @@ hoe = Hoe.new(GEM_NAME, VERS) do |p|
58
58
 
59
59
  # == Optional
60
60
  p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
61
- p.extra_deps = [ ['activesupport', '>= 2.0.2'], ['highline', '>= 1.4.0'], ['capistrano', '>= 2.2.0'] ] # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ]
61
+ p.extra_deps = [ ['activesupport', '>= 2.0.2'], ['highline', '>= 1.4.0'], ['capistrano', '>= 2.5.5'] ] # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ]
62
62
 
63
63
  #p.spec_extras = {} # A hash of extra values to set in the gemspec.
64
64
 
@@ -5,9 +5,9 @@ end
5
5
 
6
6
  package :mysql_ruby_driver do
7
7
  description 'Ruby MySQL database driver'
8
- gem 'mysql'
8
+ gem 'mysql' # :build_flags => "—with-mysql-config=/usr/local/mysql/bin/mysql_config"
9
9
 
10
10
  verify do
11
11
  ruby_can_load 'mysql'
12
12
  end
13
- end
13
+ end
@@ -0,0 +1,33 @@
1
+ module Sprinkle
2
+ module Installers
3
+ # = OpenBSD and FreeBSD Port Installer
4
+ #
5
+ # The Port installer installs OpenBSD and FreeBSD ports.
6
+ # Before usage, the ports sytem must be installed and
7
+ # read on the target operating system.
8
+ #
9
+ # == Example Usage
10
+ #
11
+ # Installing the magic_beans port.
12
+ #
13
+ # package :magic_beans do
14
+ # bsd_port 'magic/magic_beans'
15
+ # end
16
+ #
17
+ class BsdPort < Installer
18
+ attr_accessor :port #:nodoc:
19
+
20
+ def initialize(parent, port, &block) #:nodoc:
21
+ super parent, &block
22
+ @port = port
23
+ end
24
+
25
+ protected
26
+
27
+ def install_commands #:nodoc:
28
+ "sh -c 'cd /usr/ports/#{@port} && make BATCH=yes install clean'"
29
+ end
30
+
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,37 @@
1
+ module Sprinkle
2
+ module Installers
3
+ # = FreeBSD Package Installer
4
+ #
5
+ # The Pkg package installer installs FreeBSD packages.
6
+ #
7
+ # == Example Usage
8
+ #
9
+ # Installing the magic_beans package.
10
+ #
11
+ # package :magic_beans do
12
+ # freebsd_pkg 'magic_beans'
13
+ # end
14
+ #
15
+ # You may also specify multiple packages as an array:
16
+ #
17
+ # package :magic_beans do
18
+ # freebsd_pkg %w(magic_beans magic_sauce)
19
+ # end
20
+ class FreebsdPkg < Installer
21
+ attr_accessor :packages #:nodoc:
22
+
23
+ def initialize(parent, packages, &block) #:nodoc:
24
+ super parent, &block
25
+ packages = [packages] unless packages.is_a? Array
26
+ @packages = packages
27
+ end
28
+
29
+ protected
30
+
31
+ def install_commands #:nodoc:
32
+ "pkg_add -r #{@packages.join(' ')}"
33
+ end
34
+
35
+ end
36
+ end
37
+ end
@@ -54,6 +54,7 @@ module Sprinkle
54
54
  cmd << " --source #{source}" if source
55
55
  cmd << " --install-dir #{repository}" if option?(:repository)
56
56
  cmd << " --no-rdoc --no-ri" unless option?(:build_docs)
57
+ cmd << " -- #{build_flags}" if option?(:build_flags)
57
58
  cmd
58
59
  end
59
60
 
@@ -0,0 +1,38 @@
1
+ module Sprinkle
2
+ module Installers
3
+ # = Mac OS X Port Installer (macports)
4
+ #
5
+ # The Port installer installs macports ports.
6
+ #
7
+ # == Example Usage
8
+ #
9
+ # Installing the magic_beans port.
10
+ #
11
+ # package :magic_beans do
12
+ # mac_port 'magic/magic_beans'
13
+ # end
14
+ #
15
+ # == Notes
16
+ # Before MacPorts packages can be installed, the PATH
17
+ # environment variable probably has to be changed so
18
+ # capistrano can find the /opt/local/bin/port executable
19
+ #
20
+ # You must set PATH in ~/.ssh/environment on the remote
21
+ # system and enable 'PermitUserEnvironment yes' in /etc/sshd_config
22
+ class MacPort < Installer
23
+ attr_accessor :port #:nodoc:
24
+
25
+ def initialize(parent, port, &block) #:nodoc:
26
+ super parent, &block
27
+ @port = port
28
+ end
29
+
30
+ protected
31
+
32
+ def install_commands #:nodoc:
33
+ "port install #{@port}"
34
+ end
35
+
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,47 @@
1
+ module Sprinkle
2
+ module Installers
3
+ # = OpenBSD Package Installer
4
+ #
5
+ # The Pkg package installer installs OpenBSD packages.
6
+ #
7
+ # == Example Usage
8
+ #
9
+ # Installing the magic_beans package.
10
+ #
11
+ # package :magic_beans do
12
+ # openbsd_pkg 'magic_beans'
13
+ # end
14
+ #
15
+ # You may also specify multiple packages as an array:
16
+ #
17
+ # package :magic_beans do
18
+ # openbsd_pkg %w(magic_beans magic_sauce)
19
+ # end
20
+ #
21
+ # == Notes
22
+ # Before OpenBSD packages can be installed, the PKG_PATH
23
+ # environment variable must be set.
24
+ #
25
+ # You must set PKG_PATH in ~/.ssh/environment on the remote
26
+ # system and enable 'PermitUserEnvironment yes' in /etc/ssh/sshd_config
27
+ #
28
+ # For help on PKG_PATH see section 15.2.2 of the OpenBSD FAQ
29
+ # (http://www.openbsd.org/faq/faq15.html)
30
+ class OpenbsdPkg < Installer
31
+ attr_accessor :packages #:nodoc:
32
+
33
+ def initialize(parent, packages, &block) #:nodoc:
34
+ super parent, &block
35
+ packages = [packages] unless packages.is_a? Array
36
+ @packages = packages
37
+ end
38
+
39
+ protected
40
+
41
+ def install_commands #:nodoc:
42
+ "pkg_add #{@packages.join(' ')}"
43
+ end
44
+
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,43 @@
1
+ module Sprinkle
2
+ module Installers
3
+ # = OpenSolaris Package Installer
4
+ #
5
+ # The Pkg package installer installs OpenSolaris packages.
6
+ #
7
+ # == Example Usage
8
+ #
9
+ # Installing the magic_beans package.
10
+ #
11
+ # package :magic_beans do
12
+ # opensolaris_pkg 'magic_beans'
13
+ # end
14
+ #
15
+ # You may also specify multiple packages as an array:
16
+ #
17
+ # package :magic_beans do
18
+ # opensolaris_pkg %w(magic_beans magic_sauce)
19
+ # end
20
+ #
21
+ # == Note
22
+ # If you are using capistrano as the deployment method
23
+ # you will need to add the following lines to your deploy.rb
24
+ # set :sudo, 'pfexec'
25
+ # set :sudo_prompt, ''
26
+ class OpensolarisPkg < Installer
27
+ attr_accessor :packages #:nodoc:
28
+
29
+ def initialize(parent, packages, &block) #:nodoc:
30
+ super parent, &block
31
+ packages = [packages] unless packages.is_a? Array
32
+ @packages = packages
33
+ end
34
+
35
+ protected
36
+
37
+ def install_commands #:nodoc:
38
+ "pkg install #{@packages.join(' ')}"
39
+ end
40
+
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,45 @@
1
+ module Sprinkle
2
+ module Installers
3
+ # Beware, strange "installer" coming your way.
4
+ #
5
+ # = Text configuration installer
6
+ #
7
+ # This installer pushes simple configuration into a file.
8
+ #
9
+ # == Example Usage
10
+ #
11
+ # Installing magic_beans into apache2.conf
12
+ #
13
+ # package :magic_beans do
14
+ # push_text 'magic_beans', '/etc/apache2/apache2.conf'
15
+ # end
16
+ #
17
+ # If you user has access to 'sudo' and theres a file that requires
18
+ # priveledges, you can pass :sudo => true
19
+ #
20
+ # package :magic_beans do
21
+ # push_text 'magic_beans', '/etc/apache2/apache2.conf', :sudo => true
22
+ # end
23
+ #
24
+ # A special verify step exists for this very installer
25
+ # its known as file_contains, it will test that a file indeed
26
+ # contains a substring that you send it.
27
+ #
28
+ class PushText < Installer
29
+ attr_accessor :text, :path #:nodoc:
30
+
31
+ def initialize(parent, text, path, options={}, &block) #:nodoc:
32
+ super parent, options, &block
33
+ @text = text
34
+ @path = path
35
+ end
36
+
37
+ protected
38
+
39
+ def install_commands #:nodoc:
40
+ "echo '#{@text}' |#{'sudo' if option?(:sudo)} tee -a #{@path}"
41
+ end
42
+
43
+ end
44
+ end
45
+ end
@@ -29,7 +29,7 @@ module Sprinkle
29
29
  protected
30
30
 
31
31
  def install_commands #:nodoc:
32
- "yum #{@packages.join(' ')} -y"
32
+ "yum install #{@packages.join(' ')} -y"
33
33
  end
34
34
 
35
35
  end
@@ -120,6 +120,26 @@ module Sprinkle
120
120
  self.instance_eval &block
121
121
  end
122
122
 
123
+ def freebsd_pkg(*names, &block)
124
+ @installer = Sprinkle::Installers::FreebsdPkg.new(self, *names, &block)
125
+ end
126
+
127
+ def openbsd_pkg(*names, &block)
128
+ @installer = Sprinkle::Installers::OpenbsdPkg.new(self, *names, &block)
129
+ end
130
+
131
+ def opensolaris_pkg(*names, &block)
132
+ @installer = Sprinkle::Installers::OpensolarisPkg.new(self, *names, &block)
133
+ end
134
+
135
+ def bsd_port(port, &block)
136
+ @installer = Sprinkle::Installers::BsdPort.new(self, port, &block)
137
+ end
138
+
139
+ def mac_port(port, &block)
140
+ @installer = Sprinkle::Installers::MacPort.new(self, port, &block)
141
+ end
142
+
123
143
  def apt(*names, &block)
124
144
  @installer = Sprinkle::Installers::Apt.new(self, *names, &block)
125
145
  end
@@ -150,6 +170,10 @@ module Sprinkle
150
170
  @installer = Sprinkle::Installers::Rake.new(self, name, options, &block)
151
171
  end
152
172
 
173
+ def push_text(text, path, options = {}, &block)
174
+ @installer = Sprinkle::Installers::PushText.new(self, text, path, options, &block)
175
+ end
176
+
153
177
  def verify(description = '', &block)
154
178
  @verifications << Sprinkle::Verify.new(self, description, &block)
155
179
  end
@@ -8,6 +8,8 @@ module Sprinkle
8
8
  #
9
9
  # verify { has_file '/etc/apache2/apache2.conf' }
10
10
  #
11
+ # verify { file_contains '/etc/apache2/apache2.conf', 'mod_gzip'}
12
+ #
11
13
  module File
12
14
  Sprinkle::Verify.register(Sprinkle::Verifiers::File)
13
15
 
@@ -15,6 +17,10 @@ module Sprinkle
15
17
  def has_file(path)
16
18
  @commands << "test -f #{path}"
17
19
  end
20
+
21
+ def file_contains(path, text)
22
+ @commands << "grep '#{text}' #{path}"
23
+ end
18
24
  end
19
25
  end
20
26
  end
@@ -2,7 +2,7 @@ module Sprinkle #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 2
5
- TINY = 0
5
+ TINY = 1
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -0,0 +1,42 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe Sprinkle::Installers::BsdPort do
4
+
5
+ before do
6
+ @package = mock(Sprinkle::Package, :name => 'package')
7
+ end
8
+
9
+ def create_port(ports, &block)
10
+ Sprinkle::Installers::BsdPort.new(@package, ports, &block)
11
+ end
12
+
13
+ describe 'when created' do
14
+
15
+ it 'should accept a single package to install' do
16
+ @installer = create_port 'lang/ruby'
17
+ @installer.port.should == 'lang/ruby'
18
+ end
19
+
20
+ end
21
+
22
+ describe 'during installation' do
23
+
24
+ before do
25
+ @installer = create_port 'lang/ruby' do
26
+ pre :install, 'op1'
27
+ post :install, 'op2'
28
+ end
29
+ @install_commands = @installer.send :install_commands
30
+ end
31
+
32
+ it 'should invoke the port installer for all specified packages' do
33
+ @install_commands.should =~ /cd \/usr\/ports\/lang\/ruby && make BATCH=yes install clean/
34
+ end
35
+
36
+ it 'should automatically insert pre/post commands for the specified package' do
37
+ @installer.send(:install_sequence).should == [ 'op1', 'sh -c \'cd /usr/ports/lang/ruby && make BATCH=yes install clean\'', 'op2' ]
38
+ end
39
+
40
+ end
41
+
42
+ end
@@ -0,0 +1,49 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe Sprinkle::Installers::FreebsdPkg do
4
+
5
+ before do
6
+ @package = mock(Sprinkle::Package, :name => 'package')
7
+ end
8
+
9
+ def create_pkg(pkgs, &block)
10
+ Sprinkle::Installers::FreebsdPkg.new(@package, pkgs, &block)
11
+ end
12
+
13
+ describe 'when created' do
14
+
15
+ it 'should accept a single package to install' do
16
+ @installer = create_pkg 'ruby'
17
+ @installer.packages.should == [ 'ruby' ]
18
+ end
19
+
20
+ it 'should accept an array of packages to install' do
21
+ @installer = create_pkg %w( gcc gdb g++ )
22
+ @installer.packages.should == ['gcc', 'gdb', 'g++']
23
+ end
24
+
25
+ end
26
+
27
+ describe 'during installation' do
28
+
29
+ before do
30
+ @installer = create_pkg 'ruby' do
31
+ pre :install, 'op1'
32
+ post :install, 'op2'
33
+ end
34
+ @install_commands = @installer.send :install_commands
35
+ end
36
+
37
+ it 'should invoke the freebsd_pkg installer for all specified packages' do
38
+ @install_commands.should =~ /pkg_add -r ruby/
39
+ end
40
+
41
+ it 'should automatically insert pre/post commands for the specified package' do
42
+ @installer.send(:install_sequence).should == [ 'op1', 'pkg_add -r ruby', 'op2' ]
43
+ end
44
+
45
+ it 'should install a specific version if defined'
46
+
47
+ end
48
+
49
+ end
@@ -5,7 +5,7 @@ describe Sprinkle::Installers::Gem do
5
5
  before do
6
6
  @gem = 'rails'
7
7
  @version = '2.0.2'
8
- @options = { :source => 'http://gems.github.com/', :repository => '/tmp/gems' }
8
+ @options = { :source => 'http://gems.github.com/', :repository => '/tmp/gems', :build_flags => '--build_flag=foo' }
9
9
  end
10
10
 
11
11
  def create_gem(gem, version = nil, options = {}, &block)
@@ -34,6 +34,10 @@ describe Sprinkle::Installers::Gem do
34
34
  it 'should optionally store the repository location where gems are to be installed' do
35
35
  @installer.repository.should == @options[:repository]
36
36
  end
37
+
38
+ it 'should optionally store the build flags' do
39
+ @installer.build_flags.should == @options[:build_flags]
40
+ end
37
41
 
38
42
  end
39
43
 
@@ -70,6 +74,18 @@ describe Sprinkle::Installers::Gem do
70
74
 
71
75
  end
72
76
 
77
+ describe 'with build flags' do
78
+
79
+ before do
80
+ @installer = create_gem @gem, nil, :build_flags => '--option=foo'
81
+ end
82
+
83
+ it 'should install with defined build flags' do
84
+ @installer.send(:install_commands).should == "gem install #{@gem} --no-rdoc --no-ri -- --option=foo"
85
+ end
86
+
87
+ end
88
+
73
89
  end
74
90
 
75
91
  end
@@ -0,0 +1,42 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe Sprinkle::Installers::MacPort do
4
+
5
+ before do
6
+ @package = mock(Sprinkle::Package, :name => 'package')
7
+ end
8
+
9
+ def create_port(ports, &block)
10
+ Sprinkle::Installers::MacPort.new(@package, ports, &block)
11
+ end
12
+
13
+ describe 'when created' do
14
+
15
+ it 'should accept a single package to install' do
16
+ @installer = create_port 'ruby'
17
+ @installer.port.should == 'ruby'
18
+ end
19
+
20
+ end
21
+
22
+ describe 'during installation' do
23
+
24
+ before do
25
+ @installer = create_port 'ruby' do
26
+ pre :install, 'op1'
27
+ post :install, 'op2'
28
+ end
29
+ @install_commands = @installer.send :install_commands
30
+ end
31
+
32
+ it 'should invoke the port installer for all specified packages' do
33
+ @install_commands.should =~ /port install ruby/
34
+ end
35
+
36
+ it 'should automatically insert pre/post commands for the specified package' do
37
+ @installer.send(:install_sequence).should == [ 'op1', 'port install ruby', 'op2' ]
38
+ end
39
+
40
+ end
41
+
42
+ end
@@ -0,0 +1,49 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe Sprinkle::Installers::OpenbsdPkg do
4
+
5
+ before do
6
+ @package = mock(Sprinkle::Package, :name => 'package')
7
+ end
8
+
9
+ def create_pkg(pkgs, &block)
10
+ Sprinkle::Installers::OpenbsdPkg.new(@package, pkgs, &block)
11
+ end
12
+
13
+ describe 'when created' do
14
+
15
+ it 'should accept a single package to install' do
16
+ @installer = create_pkg 'ruby'
17
+ @installer.packages.should == [ 'ruby' ]
18
+ end
19
+
20
+ it 'should accept an array of packages to install' do
21
+ @installer = create_pkg %w( gcc gdb g++ )
22
+ @installer.packages.should == ['gcc', 'gdb', 'g++']
23
+ end
24
+
25
+ end
26
+
27
+ describe 'during installation' do
28
+
29
+ before do
30
+ @installer = create_pkg 'ruby' do
31
+ pre :install, 'op1'
32
+ post :install, 'op2'
33
+ end
34
+ @install_commands = @installer.send :install_commands
35
+ end
36
+
37
+ it 'should invoke the freebsd_pkg installer for all specified packages' do
38
+ @install_commands.should =~ /pkg_add ruby/
39
+ end
40
+
41
+ it 'should automatically insert pre/post commands for the specified package' do
42
+ @installer.send(:install_sequence).should == [ 'op1', 'pkg_add ruby', 'op2' ]
43
+ end
44
+
45
+ it 'should install a specific version if defined'
46
+
47
+ end
48
+
49
+ end
@@ -0,0 +1,49 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe Sprinkle::Installers::OpensolarisPkg do
4
+
5
+ before do
6
+ @package = mock(Sprinkle::Package, :name => 'package')
7
+ end
8
+
9
+ def create_pkg(pkgs, &block)
10
+ Sprinkle::Installers::OpensolarisPkg.new(@package, pkgs, &block)
11
+ end
12
+
13
+ describe 'when created' do
14
+
15
+ it 'should accept a single package to install' do
16
+ @installer = create_pkg 'ruby'
17
+ @installer.packages.should == [ 'ruby' ]
18
+ end
19
+
20
+ it 'should accept an array of packages to install' do
21
+ @installer = create_pkg %w( gcc gdb g++ )
22
+ @installer.packages.should == ['gcc', 'gdb', 'g++']
23
+ end
24
+
25
+ end
26
+
27
+ describe 'during installation' do
28
+
29
+ before do
30
+ @installer = create_pkg 'ruby' do
31
+ pre :install, 'op1'
32
+ post :install, 'op2'
33
+ end
34
+ @install_commands = @installer.send :install_commands
35
+ end
36
+
37
+ it 'should invoke the freebsd_pkg installer for all specified packages' do
38
+ @install_commands.should =~ /pkg install ruby/
39
+ end
40
+
41
+ it 'should automatically insert pre/post commands for the specified package' do
42
+ @installer.send(:install_sequence).should == [ 'op1', 'pkg install ruby', 'op2' ]
43
+ end
44
+
45
+ it 'should install a specific version if defined'
46
+
47
+ end
48
+
49
+ end
@@ -0,0 +1,55 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe Sprinkle::Installers::PushText do
4
+
5
+ before do
6
+ @package = mock(Sprinkle::Package, :name => 'package')
7
+ @options = {:sudo => true}
8
+ end
9
+
10
+ def create_text(text, path, options={}, &block)
11
+ Sprinkle::Installers::PushText.new(@package, text, path, options, &block)
12
+ end
13
+
14
+ describe 'when created' do
15
+
16
+ it 'should accept a single package to install' do
17
+ @installer = create_text 'crazy-configuration-methods', '/etc/doomed/file.conf'
18
+ @installer.text.should == 'crazy-configuration-methods'
19
+ @installer.path.should == '/etc/doomed/file.conf'
20
+ end
21
+
22
+ end
23
+
24
+ describe 'during installation' do
25
+
26
+ before do
27
+ @installer = create_text 'another-hair-brained-idea', '/dev/mind/late-night' do
28
+ pre :install, 'op1'
29
+ post :install, 'op2'
30
+ end
31
+ @install_commands = @installer.send :install_commands
32
+ end
33
+
34
+ it 'should invoke the push text installer for all specified packages' do
35
+ @install_commands.should =~ /echo 'another-hair-brained-idea' | tee -a \/dev\/mind\/late-night/
36
+ end
37
+
38
+ it 'should automatically insert pre/post commands for the specified package' do
39
+ @installer.send(:install_sequence).should == [ 'op1', "echo 'another-hair-brained-idea' | tee -a /dev/mind/late-night", 'op2' ]
40
+ end
41
+
42
+ end
43
+
44
+ describe 'running with sudo' do
45
+ before do
46
+ @installer = create_text "I'm a special user", "/dev/mind/the-day-after", :sudo => true
47
+ @install_commands = @installer.send :install_commands
48
+ end
49
+
50
+ it "should invoke the push installer with sudo" do
51
+ @install_commands.should =~ /echo 'I\'m a special user' | sudo tee -a \/dev\/mind\/the-day-after/
52
+ end
53
+ end
54
+
55
+ end
@@ -35,11 +35,11 @@ describe Sprinkle::Installers::Yum do
35
35
  end
36
36
 
37
37
  it 'should invoke the rpm installer for all specified packages' do
38
- @install_commands.should =~ /yum ruby -y/
38
+ @install_commands.should =~ /yum install ruby -y/
39
39
  end
40
40
 
41
41
  it 'should automatically insert pre/post commands for the specified package' do
42
- @installer.send(:install_sequence).should == [ 'op1', 'yum ruby -y', 'op2' ]
42
+ @installer.send(:install_sequence).should == [ 'op1', 'yum install ruby -y', 'op2' ]
43
43
  end
44
44
 
45
45
  it 'should install a specific version if defined'
@@ -9,6 +9,9 @@ describe Sprinkle::Verify do
9
9
  # Check a file exists
10
10
  has_file 'my_file.txt'
11
11
 
12
+ # Check that a file contains a substring
13
+ file_contains 'my_file.txt', 'A sunny day on the lower east-side'
14
+
12
15
  # Check a directory exists
13
16
  has_directory 'mydir'
14
17
 
@@ -51,6 +54,10 @@ describe Sprinkle::Verify do
51
54
  @verification.commands.should include('test -f my_file.txt')
52
55
  end
53
56
 
57
+ it 'should do a grep to see if a file contains a text string' do
58
+ @verification.commands.should include("grep 'A sunny day on the lower east-side' my_file.txt")
59
+ end
60
+
54
61
  it 'should do a "test -d" on the has_directory check' do
55
62
  @verification.commands.should include('test -d mydir')
56
63
  end
data/sprinkle.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = %q{sprinkle}
3
- s.version = "0.2.0"
3
+ s.version = "0.2.1"
4
4
 
5
5
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
6
6
  s.authors = ["Marcus Crafter", "Mitchell Hashimoto"]
@@ -25,19 +25,21 @@ Gem::Specification.new do |s|
25
25
  "lib/sprinkle/extensions/string.rb", "lib/sprinkle/extensions/symbol.rb", "lib/sprinkle/installers/apt.rb",
26
26
  "lib/sprinkle/installers/deb.rb", "lib/sprinkle/installers/gem.rb", "lib/sprinkle/installers/installer.rb",
27
27
  "lib/sprinkle/installers/rake.rb", "lib/sprinkle/installers/rpm.rb", "lib/sprinkle/installers/source.rb",
28
- "lib/sprinkle/installers/yum.rb", "lib/sprinkle/package.rb", "lib/sprinkle/policy.rb", "lib/sprinkle/script.rb",
29
- "lib/sprinkle/verifiers/directory.rb", "lib/sprinkle/verifiers/executable.rb", "lib/sprinkle/verifiers/file.rb",
30
- "lib/sprinkle/verifiers/process.rb", "lib/sprinkle/verifiers/ruby.rb", "lib/sprinkle/verifiers/symlink.rb",
31
- "lib/sprinkle/verify.rb", "lib/sprinkle/version.rb", "script/destroy", "script/generate", "sprinkle.gemspec",
32
- "tasks/deployment.rake", "tasks/environment.rake", "tasks/rspec.rake"]
28
+ "lib/sprinkle/installers/yum.rb", "lib/sprinkle/installers/freebsd_pkg.rb", "lib/sprinkle/installers/openbsd_pkg.rb",
29
+ "lib/sprinkle/installers/opensolaris_pkg.rb", "lib/sprinkle/installers/bsd_port.rb", "lib/sprinkle/installers/mac_port.rb", "lib/sprinkle/installers/push_text.rb",
30
+ "lib/sprinkle/package.rb", "lib/sprinkle/policy.rb", "lib/sprinkle/script.rb", "lib/sprinkle/verifiers/directory.rb",
31
+ "lib/sprinkle/verifiers/executable.rb", "lib/sprinkle/verifiers/file.rb", "lib/sprinkle/verifiers/process.rb",
32
+ "lib/sprinkle/verifiers/ruby.rb", "lib/sprinkle/verifiers/symlink.rb", "lib/sprinkle/verify.rb", "lib/sprinkle/version.rb",
33
+ "script/destroy", "script/generate", "sprinkle.gemspec", "tasks/deployment.rake", "tasks/environment.rake", "tasks/rspec.rake"]
33
34
 
34
35
  s.test_files = ["spec/spec.opts", "spec/spec_helper.rb", "spec/sprinkle/actors/capistrano_spec.rb",
35
36
  "spec/sprinkle/actors/local_spec.rb", "spec/sprinkle/configurable_spec.rb", "spec/sprinkle/deployment_spec.rb",
36
37
  "spec/sprinkle/extensions/array_spec.rb", "spec/sprinkle/extensions/string_spec.rb", "spec/sprinkle/installers/apt_spec.rb",
37
38
  "spec/sprinkle/installers/gem_spec.rb", "spec/sprinkle/installers/installer_spec.rb", "spec/sprinkle/installers/rpm_spec.rb",
38
- "spec/sprinkle/installers/yum_spec.rb", "spec/sprinkle/installers/source_spec.rb", "spec/sprinkle/package_spec.rb",
39
- "spec/sprinkle/policy_spec.rb", "spec/sprinkle/script_spec.rb", "spec/sprinkle/sprinkle_spec.rb",
40
- "spec/sprinkle/installers/rake_spec.rb", "spec/sprinkle/verify_spec.rb"]
39
+ "spec/sprinkle/installers/yum_spec.rb", "spec/sprinkle/installers/source_spec.rb", "spec/sprinkle/installers/freebsd_pkg_spec.rb",
40
+ "spec/sprinkle/installers/openbsd_pkg_spec.rb", "spec/sprinkle/installers/opensolaris_pkg_spec.rb",
41
+ "spec/sprinkle/installers/mac_port_spec.rb", "spec/sprinkle/installers/push_text_spec.rb", "spec/sprinkle/installers/bsd_port_spec.rb", "spec/sprinkle/policy_spec.rb",
42
+ "spec/sprinkle/script_spec.rb", "spec/sprinkle/sprinkle_spec.rb", "spec/sprinkle/installers/rake_spec.rb", "spec/sprinkle/verify_spec.rb"]
41
43
  s.has_rdoc = true
42
44
  s.homepage = %q{http://sprinkle.rubyforge.org}
43
45
  s.rdoc_options = ["--main", "README.txt"]
@@ -53,19 +55,19 @@ Gem::Specification.new do |s|
53
55
  if current_version >= 3 then
54
56
  s.add_runtime_dependency(%q<activesupport>, [">= 2.0.2"])
55
57
  s.add_runtime_dependency(%q<highline>, [">= 1.4.0"])
56
- s.add_runtime_dependency(%q<capistrano>, [">= 2.2.0"])
58
+ s.add_runtime_dependency(%q<capistrano>, [">= 2.5.5"])
57
59
  s.add_development_dependency(%q<hoe>, [">= 1.8.2"])
58
60
  s.add_development_dependency(%q<echoe>, [">= 3.0.2"])
59
61
  else
60
62
  s.add_dependency(%q<activesupport>, [">= 2.0.2"])
61
63
  s.add_dependency(%q<highline>, [">= 1.4.0"])
62
- s.add_dependency(%q<capistrano>, [">= 2.2.0"])
64
+ s.add_dependency(%q<capistrano>, [">= 2.5.5"])
63
65
  s.add_dependency(%q<hoe>, [">= 1.8.2"])
64
66
  end
65
67
  else
66
68
  s.add_dependency(%q<activesupport>, [">= 2.0.2"])
67
69
  s.add_dependency(%q<highline>, [">= 1.4.0"])
68
- s.add_dependency(%q<capistrano>, [">= 2.2.0"])
70
+ s.add_dependency(%q<capistrano>, [">= 2.5.5"])
69
71
  s.add_dependency(%q<hoe>, [">= 1.8.2"])
70
72
  end
71
73
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crafterm-sprinkle
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcus Crafter
@@ -15,6 +15,7 @@ default_executable: sprinkle
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: activesupport
18
+ type: :runtime
18
19
  version_requirement:
19
20
  version_requirements: !ruby/object:Gem::Requirement
20
21
  requirements:
@@ -24,6 +25,7 @@ dependencies:
24
25
  version:
25
26
  - !ruby/object:Gem::Dependency
26
27
  name: highline
28
+ type: :runtime
27
29
  version_requirement:
28
30
  version_requirements: !ruby/object:Gem::Requirement
29
31
  requirements:
@@ -33,15 +35,17 @@ dependencies:
33
35
  version:
34
36
  - !ruby/object:Gem::Dependency
35
37
  name: capistrano
38
+ type: :runtime
36
39
  version_requirement:
37
40
  version_requirements: !ruby/object:Gem::Requirement
38
41
  requirements:
39
42
  - - ">="
40
43
  - !ruby/object:Gem::Version
41
- version: 2.2.0
44
+ version: 2.5.5
42
45
  version:
43
46
  - !ruby/object:Gem::Dependency
44
47
  name: hoe
48
+ type: :runtime
45
49
  version_requirement:
46
50
  version_requirements: !ruby/object:Gem::Requirement
47
51
  requirements:
@@ -113,6 +117,12 @@ files:
113
117
  - lib/sprinkle/installers/rpm.rb
114
118
  - lib/sprinkle/installers/source.rb
115
119
  - lib/sprinkle/installers/yum.rb
120
+ - lib/sprinkle/installers/freebsd_pkg.rb
121
+ - lib/sprinkle/installers/openbsd_pkg.rb
122
+ - lib/sprinkle/installers/opensolaris_pkg.rb
123
+ - lib/sprinkle/installers/bsd_port.rb
124
+ - lib/sprinkle/installers/mac_port.rb
125
+ - lib/sprinkle/installers/push_text.rb
116
126
  - lib/sprinkle/package.rb
117
127
  - lib/sprinkle/policy.rb
118
128
  - lib/sprinkle/script.rb
@@ -172,7 +182,12 @@ test_files:
172
182
  - spec/sprinkle/installers/rpm_spec.rb
173
183
  - spec/sprinkle/installers/yum_spec.rb
174
184
  - spec/sprinkle/installers/source_spec.rb
175
- - spec/sprinkle/package_spec.rb
185
+ - spec/sprinkle/installers/freebsd_pkg_spec.rb
186
+ - spec/sprinkle/installers/openbsd_pkg_spec.rb
187
+ - spec/sprinkle/installers/opensolaris_pkg_spec.rb
188
+ - spec/sprinkle/installers/mac_port_spec.rb
189
+ - spec/sprinkle/installers/push_text_spec.rb
190
+ - spec/sprinkle/installers/bsd_port_spec.rb
176
191
  - spec/sprinkle/policy_spec.rb
177
192
  - spec/sprinkle/script_spec.rb
178
193
  - spec/sprinkle/sprinkle_spec.rb
@@ -1,422 +0,0 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
2
-
3
- describe Sprinkle::Package do
4
- include Sprinkle::Package
5
-
6
- before do
7
- @name = :package_name
8
- @empty = Proc.new { }
9
- @opts = { }
10
- end
11
-
12
- # Kind of a messy way to do this but it works and DRYs out
13
- # the specs. Checks to make sure an installer is receiving
14
- # the block passed to it throught the package block.
15
- def check_block_forwarding_on(installer)
16
- eval(<<CODE)
17
- pre_count = 0
18
- lambda {
19
- pkg = package @name do
20
- #{installer} 'archive' do
21
- pre :install, 'preOp'
22
- end
23
- end
24
-
25
- pre_count = pkg.installer.instance_variable_get(:@pre)[:install].length
26
- }.should change { pre_count }.by(1)
27
- CODE
28
- end
29
-
30
- # More of Mitchell's meta-programming to dry up specs.
31
- def create_package_with_blank_verify(n = 1)
32
- eval(<<CODE)
33
- @pkg = package @name do
34
- gem 'gem'
35
- #{"verify 'stuff happens' do; end\n" * n}
36
- end
37
- CODE
38
- end
39
-
40
- describe 'when created' do
41
-
42
- it 'should be invalid without a block descriptor' do
43
- lambda { package @name }.should raise_error
44
- end
45
-
46
- it 'should be invalid without a name' do
47
- lambda { package nil, &@empty }.should raise_error
48
- lambda { package @name, &@empty }.should_not raise_error
49
- end
50
-
51
- it 'should optionally accept a description' do
52
- pkg = package @name do
53
- description 'my package description'
54
- end
55
- pkg.description.should == 'my package description'
56
- end
57
-
58
- it 'should optionally accept a version' do
59
- pkg = package @name do
60
- version '2.0.2'
61
- end
62
- pkg.version.should == '2.0.2'
63
- end
64
-
65
- it 'should optionally accept an installer' do
66
- pkg = package @name do
67
- gem 'rails'
68
- end
69
- pkg.installer.should_not be_nil
70
- end
71
-
72
- it 'should optionally accept dependencies' do
73
- pkg = package @name do
74
- requires :webserver, :database
75
- end
76
- pkg.dependencies.should == [:webserver, :database]
77
- end
78
-
79
- it 'should optionally accept recommended dependencies' do
80
- pkg = package @name do
81
- recommends :webserver, :database
82
- end
83
- pkg.recommends.should == [:webserver, :database]
84
- end
85
-
86
- it 'should optionally define a virtual package implementation' do
87
- pkg = package @name, :provides => :database do; end
88
- pkg.provides.should == :database
89
- end
90
-
91
- it 'should be able to represent itself as a string' do
92
- pkg = package @name do; end
93
- pkg.to_s.should == @name
94
- end
95
-
96
- end
97
-
98
- describe 'helper method' do
99
-
100
- it 'should added new packages to the global package hash' do
101
- pkg = package @name do; end
102
- Sprinkle::Package::PACKAGES[@name].should == pkg
103
- end
104
-
105
- it 'should add the new package to the provides list if specified' do
106
- pkg = package @name, :provides => :database do; end
107
- Sprinkle::Package::PACKAGES[:database].last.should == pkg
108
- end
109
-
110
- end
111
-
112
- describe 'installer configuration' do
113
-
114
- it 'should optionally accept an apt installer' do
115
- pkg = package @name do
116
- apt %w( deb1 deb2 )
117
- end
118
- pkg.should respond_to(:apt)
119
- pkg.installer.class.should == Sprinkle::Installers::Apt
120
- end
121
-
122
- it 'should optionally accept an rpm installer' do
123
- pkg = package @name do
124
- rpm %w( rpm1 rpm2 )
125
- end
126
- pkg.should respond_to(:rpm)
127
- pkg.installer.class.should == Sprinkle::Installers::Rpm
128
- end
129
-
130
- it 'should optionally accept a gem installer' do
131
- pkg = package @name do
132
- gem 'gem'
133
- end
134
- pkg.should respond_to(:gem)
135
- pkg.installer.class.should == Sprinkle::Installers::Gem
136
- end
137
-
138
- it 'should optionally accept a source installer' do
139
- pkg = package @name do
140
- source 'archive'
141
- end
142
- pkg.should respond_to(:source)
143
- pkg.installer.class.should == Sprinkle::Installers::Source
144
- end
145
-
146
- end
147
-
148
- describe 'with a source installer' do
149
-
150
- it 'should optionally accept a block containing customisations' do
151
- pkg = package @name do
152
- source 'archive' do; end
153
- end
154
- pkg.should respond_to(:source)
155
- pkg.installer.class.should == Sprinkle::Installers::Source
156
- end
157
-
158
- it 'should forward block to installer superclass' do
159
- check_block_forwarding_on(:source)
160
- end
161
-
162
- it 'should automatically add a build essential recommendation' do
163
- pkg = package @name do
164
- source 'archive'
165
- end
166
- pkg.recommends.should include(:build_essential)
167
- end
168
-
169
- end
170
-
171
- describe 'with an apt installer' do
172
- it 'should forward block to installer superclass' do
173
- check_block_forwarding_on(:apt)
174
- end
175
- end
176
-
177
- describe 'with an rpm installer' do
178
- it 'should forward block to installer superclass' do
179
- check_block_forwarding_on(:rpm)
180
- end
181
- end
182
-
183
- describe 'with an gem installer' do
184
-
185
- it 'should automatically add a rubygems recommendation' do
186
- pkg = package @name do
187
- gem 'gem'
188
- end
189
- pkg.recommends.should include(:rubygems)
190
- end
191
-
192
- it 'should forward block to installer superclass' do
193
- check_block_forwarding_on(:gem)
194
- end
195
-
196
- end
197
-
198
- describe 'when processing' do
199
-
200
- before do
201
- @deployment = mock(Sprinkle::Deployment)
202
- @roles = [ :app, :db ]
203
- @installer = mock(Sprinkle::Installers::Installer, :defaults => true, :process => true)
204
- @package = package @name do; end
205
- end
206
-
207
- describe 'with an installer' do
208
-
209
- before do
210
- @package.installer = @installer
211
- end
212
-
213
- it 'should configure itself against the deployment context' do
214
- @installer.should_receive(:defaults).with(@deployment).and_return
215
- end
216
-
217
- it 'should request the installer to process itself' do
218
- @installer.should_receive(:process).with(@roles).and_return
219
- end
220
-
221
- after do
222
- @package.process(@deployment, @roles)
223
- end
224
- end
225
-
226
- describe 'without an installer' do
227
-
228
- it 'should not request the installer to process if the package is a metapackage' do
229
- @installer.should_not_receive(:process)
230
- @package.process(@deployment, @roles)
231
- end
232
-
233
- end
234
-
235
- describe 'with verifications' do
236
- before do
237
- @pkg = create_package_with_blank_verify(3)
238
- @pkg.installer = @installer
239
- @installer.stub!(:defaults)
240
- @installer.stub!(:process)
241
- end
242
-
243
- describe 'with forcing' do
244
- before do
245
- # Being explicit
246
- Sprinkle::OPTIONS[:force] = true
247
- end
248
-
249
- it 'should process verifications only once' do
250
- @pkg.should_receive(:process_verifications).once
251
- @pkg.process(@deployment, @roles)
252
- end
253
-
254
- after do
255
- # Being explicit
256
- Sprinkle::OPTIONS[:force] = false
257
- end
258
- end
259
-
260
- describe 'without forcing' do
261
- before do
262
- # Being explicit
263
- Sprinkle::OPTIONS[:force] = false
264
- end
265
-
266
- it 'should process verifications twice' do
267
- @pkg.should_receive(:process_verifications).once.with(@deployment, @roles, true).and_raise(Sprinkle::VerificationFailed.new(@pkg, ''))
268
- @pkg.should_receive(:process_verifications).once.with(@deployment, @roles).and_raise(Sprinkle::VerificationFailed.new(@pkg, ''))
269
- end
270
-
271
- it 'should continue with installation if pre-verification fails' do
272
- @pkg.should_receive(:process_verifications).twice.and_raise(Sprinkle::VerificationFailed.new(@pkg, ''))
273
- @installer.should_receive(:defaults)
274
- @installer.should_receive(:process)
275
- end
276
-
277
- it 'should only process verifications once and should not process installer if verifications succeed' do
278
- @pkg.should_receive(:process_verifications).once.and_return(nil)
279
- @installer.should_not_receive(:defaults)
280
- @installer.should_not_receive(:process)
281
- end
282
-
283
- after do
284
- begin
285
- @pkg.process(@deployment, @roles)
286
- rescue Sprinkle::VerificationFailed => e; end
287
- end
288
- end
289
- end
290
-
291
- end
292
-
293
- describe 'when processing verifications' do
294
- before do
295
- @deployment = mock(Sprinkle::Deployment)
296
- @roles = [ :app, :db ]
297
- @installer = mock(Sprinkle::Installers::Installer, :defaults => true, :process => true)
298
- @pkg = create_package_with_blank_verify(3)
299
- @pkg.installer = @installer
300
- @installer.stub!(:defaults)
301
- @installer.stub!(:process)
302
- @logger = mock(ActiveSupport::BufferedLogger, :debug => true, :debug? => true)
303
- @logger.stub!(:info)
304
- end
305
-
306
- it 'should request _each_ verification to configure itself against the deployment context' do
307
- @pkg.verifications.each do |v|
308
- v.should_receive(:defaults).with(@deployment).once
309
- v.stub!(:process)
310
- end
311
- end
312
-
313
- it 'should request _each_ verification to process' do
314
- @pkg.verifications.each do |v|
315
- v.stub!(:defaults)
316
- v.should_receive(:process).with(@roles).once
317
- end
318
- end
319
-
320
- it 'should enter a log info event to notify user whats happening' do
321
- @pkg.verifications.each do |v|
322
- v.stub!(:defaults)
323
- v.stub!(:process)
324
- end
325
-
326
- @pkg.should_receive(:logger).once.and_return(@logger)
327
- end
328
-
329
- after do
330
- @pkg.process_verifications(@deployment, @roles)
331
- end
332
- end
333
-
334
- describe 'hierarchies' do
335
-
336
- before do
337
- @a = package :a do; requires :b; end
338
- @b = package :b do; requires :c; end
339
- @c = package :c do; recommends :d; end
340
- @d = package :d do; end
341
- end
342
-
343
- it 'should be able to return a dependency hierarchy tree' do
344
- @a.tree.flatten.should == [ @d, @c, @b, @a ]
345
- @b.tree.flatten.should == [ @d, @c, @b ]
346
- @c.tree.flatten.should == [ @d, @c ]
347
- @d.tree.flatten.should == [ @d ]
348
- end
349
-
350
- describe 'with missing recommendations' do
351
-
352
- before do
353
- @d.recommends :e
354
- end
355
-
356
- it 'should ignore missing recommendations' do
357
- @d.tree.flatten.should == [ @d ]
358
- end
359
-
360
- end
361
-
362
- it 'should optionally accept a block to call upon item in the tree during hierarchy traversal' do
363
- @count = 0
364
- @a.tree do
365
- @count += 1
366
- end
367
- @count.should == 3
368
- end
369
-
370
- it 'should maintain a depth count of how deep the hierarchy is' do
371
- @b.should_receive(:tree).with(2).and_return([@b])
372
- @a.tree do; end
373
- end
374
-
375
- end
376
-
377
- describe 'with missing dependencies' do
378
-
379
- before do
380
- @pkg = package @name do
381
- gem 'gem'
382
- requires :missing
383
- end
384
- end
385
-
386
- it 'should raise an error if a package is missing' do
387
- lambda { @pkg.tree }.should raise_error
388
- end
389
-
390
- end
391
-
392
- describe 'with verifications' do
393
- it 'should create a Sprinkle::Verification object for the verify block' do
394
- Sprinkle::Verify.should_receive(:new).once
395
-
396
- create_package_with_blank_verify
397
- end
398
-
399
- it 'should create multiple Sprinkle::Verification objects for multiple verify blocks' do
400
- Sprinkle::Verify.should_receive(:new).twice
401
-
402
- create_package_with_blank_verify(2)
403
- end
404
-
405
- it 'should add each Sprinkle::Verificaton object to the @verifications array' do
406
- @pkg = create_package_with_blank_verify(3)
407
- @pkg.verifications.length.should eql(3)
408
- end
409
-
410
- it 'should initialize Sprinkle::Verification with the package name, description, and block' do
411
- Sprinkle::Verify.should_receive(:new) do |pkg, desc|
412
- pkg.name.should eql(@name)
413
- desc.should eql('stuff happens')
414
- end
415
-
416
- # We do a should_not raise_error because if a block was NOT passed, an error
417
- # is raised. This is specced in verification_spec.rb
418
- lambda { create_package_with_blank_verify }.should_not raise_error
419
- end
420
- end
421
-
422
- end