dpkg-tools 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +198 -0
- data/MIT-LICENSE +20 -0
- data/README +17 -0
- data/Rakefile +1 -0
- data/bin/dpkg-etc +6 -0
- data/bin/dpkg-gem +6 -0
- data/bin/dpkg-rails +6 -0
- data/lib/dpkg-tools.rb +6 -0
- data/lib/dpkg-tools/command_line.rb +142 -0
- data/lib/dpkg-tools/package.rb +30 -0
- data/lib/dpkg-tools/package/builder.rb +112 -0
- data/lib/dpkg-tools/package/config.rb +96 -0
- data/lib/dpkg-tools/package/control_files.rb +24 -0
- data/lib/dpkg-tools/package/control_files/base.rb +75 -0
- data/lib/dpkg-tools/package/control_files/changelog.rb +23 -0
- data/lib/dpkg-tools/package/control_files/control.rb +148 -0
- data/lib/dpkg-tools/package/control_files/copyright.rb +27 -0
- data/lib/dpkg-tools/package/control_files/rakefile.rb +28 -0
- data/lib/dpkg-tools/package/control_files/rules.rb +29 -0
- data/lib/dpkg-tools/package/data.rb +125 -0
- data/lib/dpkg-tools/package/etc.rb +26 -0
- data/lib/dpkg-tools/package/etc/builder.rb +19 -0
- data/lib/dpkg-tools/package/etc/control_files.rb +22 -0
- data/lib/dpkg-tools/package/etc/control_files/changelog.rb +30 -0
- data/lib/dpkg-tools/package/etc/control_files/rakefile.rb +18 -0
- data/lib/dpkg-tools/package/etc/data.rb +48 -0
- data/lib/dpkg-tools/package/etc/rake.rb +31 -0
- data/lib/dpkg-tools/package/etc/setup.rb +30 -0
- data/lib/dpkg-tools/package/fs_methods.rb +10 -0
- data/lib/dpkg-tools/package/gem.rb +43 -0
- data/lib/dpkg-tools/package/gem/builder.rb +77 -0
- data/lib/dpkg-tools/package/gem/control_files.rb +23 -0
- data/lib/dpkg-tools/package/gem/control_files/changelog.rb +19 -0
- data/lib/dpkg-tools/package/gem/control_files/copyright.rb +24 -0
- data/lib/dpkg-tools/package/gem/control_files/rakefile.rb +19 -0
- data/lib/dpkg-tools/package/gem/data.rb +115 -0
- data/lib/dpkg-tools/package/gem/gem_format.rb +10 -0
- data/lib/dpkg-tools/package/gem/rake.rb +37 -0
- data/lib/dpkg-tools/package/gem/setup.rb +159 -0
- data/lib/dpkg-tools/package/rails.rb +26 -0
- data/lib/dpkg-tools/package/rails/builder.rb +77 -0
- data/lib/dpkg-tools/package/rails/cap.rb +30 -0
- data/lib/dpkg-tools/package/rails/control_files.rb +22 -0
- data/lib/dpkg-tools/package/rails/control_files/changelog.rb +19 -0
- data/lib/dpkg-tools/package/rails/control_files/rakefile.rb +24 -0
- data/lib/dpkg-tools/package/rails/data.rb +160 -0
- data/lib/dpkg-tools/package/rails/rake.rb +40 -0
- data/lib/dpkg-tools/package/rails/setup.rb +84 -0
- data/lib/dpkg-tools/package/rake.rb +90 -0
- data/lib/dpkg-tools/package/setup.rb +145 -0
- data/lib/dpkg-tools/version.rb +23 -0
- data/spec/dpkg-tools/command_line_spec.rb +9 -0
- data/spec/dpkg-tools/package/builder_spec.rb +159 -0
- data/spec/dpkg-tools/package/config_spec.rb +150 -0
- data/spec/dpkg-tools/package/control_files/base_spec.rb +111 -0
- data/spec/dpkg-tools/package/control_files/changelog_spec.rb +22 -0
- data/spec/dpkg-tools/package/control_files/control_spec.rb +131 -0
- data/spec/dpkg-tools/package/control_files/copyright_spec.rb +29 -0
- data/spec/dpkg-tools/package/control_files/rakefile_spec.rb +37 -0
- data/spec/dpkg-tools/package/control_files/rules_spec.rb +16 -0
- data/spec/dpkg-tools/package/control_files_spec.rb +12 -0
- data/spec/dpkg-tools/package/data_spec.rb +115 -0
- data/spec/dpkg-tools/package/etc/builder_spec.rb +28 -0
- data/spec/dpkg-tools/package/etc/control_files/changelog_spec.rb +21 -0
- data/spec/dpkg-tools/package/etc/control_files/rakefile_spec.rb +16 -0
- data/spec/dpkg-tools/package/etc/control_files_spec.rb +12 -0
- data/spec/dpkg-tools/package/etc/data_spec.rb +74 -0
- data/spec/dpkg-tools/package/etc/rake_spec.rb +71 -0
- data/spec/dpkg-tools/package/etc/setup_spec.rb +62 -0
- data/spec/dpkg-tools/package/etc_spec.rb +39 -0
- data/spec/dpkg-tools/package/fs_methods_spec.rb +33 -0
- data/spec/dpkg-tools/package/gem/builder_spec.rb +84 -0
- data/spec/dpkg-tools/package/gem/control_files/changelog_spec.rb +25 -0
- data/spec/dpkg-tools/package/gem/control_files/copyright_spec.rb +28 -0
- data/spec/dpkg-tools/package/gem/control_files/rakefile_spec.rb +17 -0
- data/spec/dpkg-tools/package/gem/control_files_spec.rb +12 -0
- data/spec/dpkg-tools/package/gem/data_spec.rb +176 -0
- data/spec/dpkg-tools/package/gem/gem_format_spec.rb +26 -0
- data/spec/dpkg-tools/package/gem/rake_spec.rb +102 -0
- data/spec/dpkg-tools/package/gem/setup_spec.rb +274 -0
- data/spec/dpkg-tools/package/gem_spec.rb +68 -0
- data/spec/dpkg-tools/package/rails/builder_spec.rb +113 -0
- data/spec/dpkg-tools/package/rails/cap_spec.rb +37 -0
- data/spec/dpkg-tools/package/rails/control_files/changelog_spec.rb +25 -0
- data/spec/dpkg-tools/package/rails/control_files/rakefile_spec.rb +24 -0
- data/spec/dpkg-tools/package/rails/control_files_spec.rb +12 -0
- data/spec/dpkg-tools/package/rails/data_spec.rb +178 -0
- data/spec/dpkg-tools/package/rails/rake_spec.rb +78 -0
- data/spec/dpkg-tools/package/rails/setup_spec.rb +152 -0
- data/spec/dpkg-tools/package/rails_spec.rb +27 -0
- data/spec/dpkg-tools/package/rake_spec.rb +87 -0
- data/spec/dpkg-tools/package/setup_spec.rb +247 -0
- data/spec/dpkg-tools/package_spec.rb +34 -0
- data/spec/fixtures/BlueCloth-1.0.0.gem +1190 -0
- data/spec/fixtures/database.yml +33 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +52 -0
- data/tasks/dist.rake +118 -0
- data/tasks/rspec.rake +21 -0
- metadata +165 -0
@@ -0,0 +1,68 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
describe DpkgTools::Package::Gem do
|
4
|
+
before(:each) do
|
5
|
+
@setup = mock('mock DpkgTools::Package::Gem::Setup')
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should be able to create package structure from a path to a gem file" do
|
9
|
+
DpkgTools::Package::Gem::Setup.expects(:from_path).with('path/to/stub.gem').returns(@setup)
|
10
|
+
@setup.expects(:create_structure)
|
11
|
+
|
12
|
+
DpkgTools::Package::Gem.setup_from_path('path/to/stub.gem', {:ignore_dependencies => true})
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should be able to create package structure from a path to a gem file, ignoring dependency-related options" do
|
16
|
+
DpkgTools::Package::Gem::Setup.expects(:from_path).with('path/to/stub.gem').returns(@setup)
|
17
|
+
@setup.expects(:create_structure)
|
18
|
+
|
19
|
+
DpkgTools::Package::Gem.setup_from_path('path/to/stub.gem', {:ignore_dependencies => false})
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should be able to create package structure from the name of a gem" do
|
23
|
+
DpkgTools::Package::Gem::Setup.expects(:from_name).with('stub_gem').returns(@setup)
|
24
|
+
@setup.expects(:create_structure)
|
25
|
+
|
26
|
+
DpkgTools::Package::Gem.setup_from_name('stub_gem', {:ignore_dependencies => true})
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should be able to create package structure and fetch dependencies" do
|
30
|
+
DpkgTools::Package::Gem::Setup.expects(:from_name).with('stub_gem').returns(@setup)
|
31
|
+
mock_dependency_setup = mock('mock DpkgTools::Package::Gem::Setup for dependency')
|
32
|
+
mock_dependency_setup.expects(:create_structure)
|
33
|
+
|
34
|
+
@setup.expects(:fetch_dependencies).returns([mock_dependency_setup])
|
35
|
+
@setup.expects(:create_structure)
|
36
|
+
|
37
|
+
DpkgTools::Package::Gem.setup_from_name('stub_gem', {})
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe DpkgTools::Package::Gem, ".config_cache method" do
|
42
|
+
before(:each) do
|
43
|
+
DpkgTools::Package::Gem.instance_variable_set(:@config_cache, {})
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should create and return a DpkgTools::Package::Config instance corresponding to the given full name key" do
|
47
|
+
DpkgTools::Package::Config.expects(:new).with('gem_name', '1.0.8', {:suffix => 'rubygem'}).returns(:config)
|
48
|
+
DpkgTools::Package::Gem.config_cache(['gem_name', '1.0.8']).should == :config
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should only create and return a single DpkgTools::Package::Config instance" do
|
52
|
+
DpkgTools::Package::Gem.config_cache(['gem_name', '1.0.8']).should === DpkgTools::Package::Gem.config_cache(['gem_name', '1.0.8'])
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should yield the Config instance if passed a block" do
|
56
|
+
result = nil
|
57
|
+
DpkgTools::Package::Gem.config_cache(['gem_name', '1.0.8']) {|cfg| result = cfg}
|
58
|
+
result.should == DpkgTools::Package::Gem.config_cache(['gem_name', '1.0.8'])
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe DpkgTools::Package::Gem, ".create_builder" do
|
63
|
+
it "should instantiate a Package::Gem::Data and a Package::Gem::Builder and make 'em work" do
|
64
|
+
DpkgTools::Package::Gem::Builder.expects(:from_file_path).with('a/path/to/stub_gem-1.1.0/stub_gem-1.1.0.gem').returns(:builder)
|
65
|
+
|
66
|
+
DpkgTools::Package::Gem.create_builder('a/path/to/stub_gem-1.1.0/stub_gem-1.1.0.gem').should == :builder
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
|
3
|
+
describe DpkgTools::Package::Rails::Builder do
|
4
|
+
it "should be able to grab all needed config stuff and create a DpkgTools::Package::Rails::Data and a Builder instance" do
|
5
|
+
DpkgTools::Package::Rails::Data.expects(:new).with('/path/to/app').returns(:data)
|
6
|
+
DpkgTools::Package::Rails::Builder.expects(:new).with(:data).returns(:instance)
|
7
|
+
|
8
|
+
DpkgTools::Package::Rails::Builder.from_path('/path/to/app').should == :instance
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe DpkgTools::Package::Rails::Builder, "instances" do
|
13
|
+
before(:each) do
|
14
|
+
@config = DpkgTools::Package::Config.new('rails-app', '1.0.8')
|
15
|
+
DpkgTools::Package::Rails::Data.expects(:load_package_data).with('/a/path/to/rails-app/working/dir', 'deb.yml').
|
16
|
+
returns({'name' => 'rails-app', 'version' => '1.0.8', 'server_name' => 'rails-app.org'}, 'mongrel_cluster' => {'port' => '8000', 'servers' => 3})
|
17
|
+
DpkgTools::Package::Rails::Data.expects(:load_package_data).with('/a/path/to/rails-app/working/dir', 'database.yml').
|
18
|
+
returns({'development' => {'database' => 'db_name'}})
|
19
|
+
@data = DpkgTools::Package::Rails::Data.new('/a/path/to/rails-app/working/dir')
|
20
|
+
|
21
|
+
@builder = DpkgTools::Package::Rails::Builder.new(@data)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should provide the correct options for DpkgTools::Package::Config " do
|
25
|
+
@builder.config_options.should == {:base_path => "/a/path/to/rails-app/working/dir"}
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should be able to create the needed install dirs" do
|
29
|
+
@builder.expects(:create_dir_if_needed).with('/a/path/to/rails-app/working/dir/debian/tmp/etc/init.d')
|
30
|
+
@builder.expects(:create_dir_if_needed).with('/a/path/to/rails-app/working/dir/debian/tmp/etc/apache2/sites-available')
|
31
|
+
@builder.expects(:create_dir_if_needed).with('/a/path/to/rails-app/working/dir/debian/tmp/etc/logrotate.d')
|
32
|
+
@builder.expects(:create_dir_if_needed).with('/a/path/to/rails-app/working/dir/debian/tmp/var/lib/rails-app')
|
33
|
+
@builder.expects(:create_dir_if_needed).with('/a/path/to/rails-app/working/dir/debian/tmp/var/log/rails-app/apache2')
|
34
|
+
|
35
|
+
@builder.create_install_dirs
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should be able to generate a config file from @data, an erb template and a destination path" do
|
39
|
+
File.expects(:read).with('template_path').returns('template')
|
40
|
+
|
41
|
+
@builder.expects(:render_template).with('template').returns('conf file')
|
42
|
+
|
43
|
+
mock_file = mock('File')
|
44
|
+
mock_file.expects(:write).with('conf file')
|
45
|
+
File.expects(:open).with('target_path', 'w').yields(mock_file)
|
46
|
+
|
47
|
+
@builder.generate_conf_file('template_path', 'target_path')
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should generate all the needed config files" do
|
51
|
+
@builder.expects(:generate_conf_file).with('/a/path/to/rails-app/working/dir/config/apache.conf.erb',
|
52
|
+
'/a/path/to/rails-app/working/dir/debian/tmp/etc/apache2/sites-available/rails-app')
|
53
|
+
|
54
|
+
@builder.expects(:generate_conf_file).with('/a/path/to/rails-app/working/dir/config/logrotate.conf.erb',
|
55
|
+
'/a/path/to/rails-app/working/dir/debian/tmp/etc/logrotate.d/rails-app')
|
56
|
+
|
57
|
+
@builder.expects(:generate_conf_file).with('/a/path/to/rails-app/working/dir/config/mongrel_cluster_init.erb',
|
58
|
+
'/a/path/to/rails-app/working/dir/debian/tmp/etc/init.d/rails-app')
|
59
|
+
|
60
|
+
@builder.generate_conf_files
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should be able to read the public ssh keys in deployers_ssh_keys" do
|
64
|
+
@data.stubs(:deployers_ssh_keys_dir).returns('/path/to/keys')
|
65
|
+
Dir.stubs(:entries).with('/path/to/keys').returns(['key1', 'key2'])
|
66
|
+
File.stubs(:file?).returns(true)
|
67
|
+
File.expects(:read).with('/path/to/keys/key1').returns('key1')
|
68
|
+
File.expects(:read).with('/path/to/keys/key2').returns('key2')
|
69
|
+
|
70
|
+
@builder.read_deployers_ssh_keys.should == ['key1', 'key2']
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should be able to read the public ssh keys in deployers_ssh_keys, ignoring any directories there" do
|
74
|
+
@data.stubs(:deployers_ssh_keys_dir).returns('/path/to/keys')
|
75
|
+
Dir.stubs(:entries).with('/path/to/keys').returns(['is_a_dir', 'key1', 'key2'])
|
76
|
+
File.stubs(:file?).returns(true)
|
77
|
+
File.expects(:file?).with('/path/to/keys/is_a_dir').returns(false)
|
78
|
+
File.expects(:read).with('/path/to/keys/key1').returns('key1')
|
79
|
+
File.expects(:read).with('/path/to/keys/key2').returns('key2')
|
80
|
+
|
81
|
+
@builder.read_deployers_ssh_keys.should == ['key1', 'key2']
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should be able to write out an authorized_keys file from a list of keys" do
|
85
|
+
mock_file = mock('File')
|
86
|
+
mock_file.expects(:write).with("key1\nkey2")
|
87
|
+
File.expects(:open).with('/a/path/to/rails-app/working/dir/debian/tmp/var/lib/rails-app/.ssh/authorized_keys', 'w').
|
88
|
+
yields(mock_file)
|
89
|
+
@builder.expects(:sh).with('chmod 600 "/a/path/to/rails-app/working/dir/debian/tmp/var/lib/rails-app/.ssh/authorized_keys"')
|
90
|
+
|
91
|
+
@builder.write_authorized_keys(['key1', 'key2'])
|
92
|
+
end
|
93
|
+
|
94
|
+
it "should be able to generate the authorized_keys file from the public keys in deployers_ssh_keys" do
|
95
|
+
@builder.expects(:create_dir_if_needed).with('/a/path/to/rails-app/working/dir/debian/tmp/var/lib/rails-app/.ssh')
|
96
|
+
@builder.expects(:sh).with('chmod 700 "/a/path/to/rails-app/working/dir/debian/tmp/var/lib/rails-app/.ssh"')
|
97
|
+
|
98
|
+
@builder.expects(:read_deployers_ssh_keys).returns(['key1', 'key2'])
|
99
|
+
@builder.expects(:write_authorized_keys).with(['key1', 'key2'])
|
100
|
+
|
101
|
+
@builder.generate_authorized_keys
|
102
|
+
end
|
103
|
+
|
104
|
+
it "should be able to perform all the needed steps to put install the package's files " do
|
105
|
+
@builder.expects(:generate_conf_files)
|
106
|
+
@builder.expects(:sh).with('chown -R root:root "/a/path/to/rails-app/working/dir/debian/tmp"')
|
107
|
+
@builder.expects(:sh).with('chmod 755 "/a/path/to/rails-app/working/dir/debian/tmp/etc/init.d/rails-app"')
|
108
|
+
|
109
|
+
@builder.expects(:generate_authorized_keys)
|
110
|
+
|
111
|
+
@builder.install_package_files
|
112
|
+
end
|
113
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
|
3
|
+
describe DpkgTools::Package::Rails::Cap, "variables for use in Cap 2 recipes" do
|
4
|
+
it "should be able to tell if the current dir has the app's config dir in it" do
|
5
|
+
Dir.stubs(:entries).with('path').returns(['.', '..', 'app', 'config'])
|
6
|
+
DpkgTools::Package::Rails::Cap.dir_contains_config?('path').should be_true
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should be able to work out where the root of the app is" do
|
10
|
+
Dir.stubs(:pwd).returns('/a/path/to/rails-app')
|
11
|
+
DpkgTools::Package::Rails::Cap.stubs(:dir_contains_config?).returns(true)
|
12
|
+
DpkgTools::Package::Rails::Cap.located_app_root.should == '/a/path/to/rails-app'
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should be able to hunt back up the path if necessary" do
|
16
|
+
Dir.stubs(:pwd).returns('/a/path/to/rails-app/app/models')
|
17
|
+
DpkgTools::Package::Rails::Cap.stubs(:dir_contains_config?).with('/a/path/to/rails-app/app/models').returns(false)
|
18
|
+
DpkgTools::Package::Rails::Cap.stubs(:dir_contains_config?).with('/a/path/to/rails-app/app').returns(false)
|
19
|
+
DpkgTools::Package::Rails::Cap.stubs(:dir_contains_config?).with('/a/path/to/rails-app').returns(true)
|
20
|
+
|
21
|
+
DpkgTools::Package::Rails::Cap.located_app_root.should == '/a/path/to/rails-app'
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should raise an error if it has to hunt back to / for the app's root" do
|
25
|
+
Dir.stubs(:pwd).returns('/a/path/to/rails-app')
|
26
|
+
DpkgTools::Package::Rails::Cap.stubs(:dir_contains_config?).returns(false)
|
27
|
+
|
28
|
+
lambda { DpkgTools::Package::Rails::Cap.located_app_root }.should raise_error(DpkgTools::Package::Rails::CannotLocateAppDir)
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should be able to return a DpkgTools::Package::Rails::Data instance" do
|
32
|
+
DpkgTools::Package::Rails::Cap.stubs(:located_app_root).returns('/a/path/to/rails-app')
|
33
|
+
DpkgTools::Package::Rails::Data.expects(:new).with('/a/path/to/rails-app').returns(:data)
|
34
|
+
|
35
|
+
DpkgTools::Package::Rails.cap.should == :data
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../../spec_helper'
|
2
|
+
|
3
|
+
describe DpkgTools::Package::Rails::ControlFiles::Changelog, "#changelog" do
|
4
|
+
before(:each) do
|
5
|
+
config = DpkgTools::Package::Config.new('rails-app', '1.0.8')
|
6
|
+
stub_data = stub('DpkgTools::Package::Rails::Data', :full_name => 'rails-app-1.0.8', :debian_revision => '1')
|
7
|
+
@metadata = DpkgTools::Package::Rails::ControlFiles::Changelog.new(stub_data, config)
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should be able to generate the current time formatted as per RFC 822" do
|
11
|
+
mock_time = mock('Time')
|
12
|
+
mock_time.expects(:rfc822).returns('rfc_time')
|
13
|
+
Time.expects(:now).returns(mock_time)
|
14
|
+
|
15
|
+
@metadata.change_time.should == 'rfc_time'
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should be able to generate a changelog" do
|
19
|
+
@metadata.expects(:change_time).returns('RFC 822 change time')
|
20
|
+
|
21
|
+
@metadata.changelog.should == "rails-app (1.0.8-1) cp-gutsy; urgency=low\n"\
|
22
|
+
" * Packaged up rails-app-1.0.8\n"\
|
23
|
+
" -- Matt Patterson <matt@reprocessed.org> RFC 822 change time\n"
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../../spec_helper'
|
2
|
+
|
3
|
+
describe DpkgTools::Package::Rails::ControlFiles::Rakefile do
|
4
|
+
before(:each) do
|
5
|
+
config = DpkgTools::Package::Config.new("rails-app", "1.0.8", :base_path => '/a/path/to/app')
|
6
|
+
stub_data = stub("DpkgTools::Package::Rails::Data", :full_name => "rails-app-1.0.8")
|
7
|
+
@control_file = DpkgTools::Package::Rails::ControlFiles::Rakefile.new(stub_data, config)
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should be able to generate the contents of the Rakefile" do
|
11
|
+
@control_file.rakefile.should == "require 'rubygems'\n" \
|
12
|
+
"begin\n" \
|
13
|
+
" require 'dpkg-tools'\n" \
|
14
|
+
"rescue LoadError\n" \
|
15
|
+
" # dpkg-tools not available (because we don't really need it on deployment targets)\n" \
|
16
|
+
"end\n" \
|
17
|
+
"\n" \
|
18
|
+
"if defined?(DpkgTools::Package::Rails)\n" \
|
19
|
+
" DpkgTools::Package::Rails::BuildTasks.new do |t|\n" \
|
20
|
+
" t.base_path = Rake.original_dir\n" \
|
21
|
+
" end\n" \
|
22
|
+
"end\n"
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
|
3
|
+
describe DpkgTools::Package::Rails::ControlFiles do
|
4
|
+
it "should provide access to the list of control file classes" do
|
5
|
+
DpkgTools::Package::Rails::ControlFiles.classes.
|
6
|
+
should == [DpkgTools::Package::Rails::ControlFiles::Changelog,
|
7
|
+
DpkgTools::Package::ControlFiles::Control,
|
8
|
+
DpkgTools::Package::ControlFiles::Copyright,
|
9
|
+
DpkgTools::Package::Rails::ControlFiles::Rakefile,
|
10
|
+
DpkgTools::Package::ControlFiles::Rules]
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,178 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
|
3
|
+
describe DpkgTools::Package::Rails::Data, ".load_package_data" do
|
4
|
+
it "should be able to read in the config/*.yml file" do
|
5
|
+
File.expects(:exist?).with('base_path/config/deb.yml').returns(true)
|
6
|
+
YAML.expects(:load_file).with('base_path/config/deb.yml').returns({"name" => 'rails-app'})
|
7
|
+
DpkgTools::Package::Rails::Data.load_package_data('base_path', 'deb.yml').should == {"name" => 'rails-app'}
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe DpkgTools::Package::Rails::Data, "base dependencies" do
|
12
|
+
it "should return a sensible list of base gem dependencies" do
|
13
|
+
DpkgTools::Package::Rails::Data.base_gem_deps.
|
14
|
+
should == [{:name => 'rails-rubygem', :requirements => ['>= 1.2.5-1']},
|
15
|
+
{:name => 'rake-rubygem', :requirements => ['>= 0.7.3-1']},
|
16
|
+
{:name => 'mysql-rubygem', :requirements => ['>= 2.7-1']},
|
17
|
+
{:name => 'mongrel-cluster-rubygem', :requirements => ['>= 1.0.1-1']}]
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should return a sensible list of base package dependencies" do
|
21
|
+
DpkgTools::Package::Rails::Data.base_deps.
|
22
|
+
should == [{:name => 'mysql-client'}, {:name => 'mysql-server'}, {:name => 'apache2'},
|
23
|
+
{:name => 'ruby', :requirements => ['>= 1.8.2']}]
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe DpkgTools::Package::Rails::Data, ".new" do
|
28
|
+
it "should raise an error without any arguments" do
|
29
|
+
lambda { DpkgTools::Package::Gem::Data.new }.should raise_error
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should take the rails app base path, then read in the config/deb.yml" do
|
33
|
+
DpkgTools::Package::Rails::Data.expects(:load_package_data).with('base_path', 'deb.yml').returns({'name' => 'rails-app', 'version' => '1.0.8'})
|
34
|
+
DpkgTools::Package::Rails::Data.expects(:load_package_data).with('base_path', 'database.yml').returns({'development' => {'database' => 'db_name'}})
|
35
|
+
DpkgTools::Package::Rails::Data.expects(:process_dependencies).with({'name' => 'rails-app', 'version' => '1.0.8'}).returns(:deps)
|
36
|
+
DpkgTools::Package::Rails::Data.new('base_path').should be_an_instance_of(DpkgTools::Package::Rails::Data)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe DpkgTools::Package::Rails::Data, "instances" do
|
41
|
+
before(:each) do
|
42
|
+
@mongrel_cluster_config_data = {'port' => '8000', 'servers' => 3}
|
43
|
+
package_data = {'name' => 'rails-app', 'version' => '1.0.8', 'license' => '(c) Matt 4evah',
|
44
|
+
'summary' => "Matt's great Rails app", 'server_name' => 'test.host',
|
45
|
+
'server_aliases' => ['www.test.host'],
|
46
|
+
'mongrel_cluster' => @mongrel_cluster_config_data}
|
47
|
+
DpkgTools::Package::Rails::Data.stubs(:load_package_data).with('base_path', 'deb.yml').
|
48
|
+
returns(package_data)
|
49
|
+
@database_configurations = YAML.load_file(File.dirname(__FILE__) + '/../../../fixtures/database.yml')
|
50
|
+
DpkgTools::Package::Rails::Data.stubs(:load_package_data).with('base_path', 'database.yml').returns(@database_configurations)
|
51
|
+
DpkgTools::Package::Rails::Data.expects(:process_dependencies).with(package_data).returns(:deps)
|
52
|
+
@data = DpkgTools::Package::Rails::Data.new('base_path')
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should provide access to its name" do
|
56
|
+
@data.name.should == 'rails-app'
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should convert the Gem::Version object to a string" do
|
60
|
+
@data.version.should == '1.0.8'
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should provide access to the changelog-derived debian_revision" do
|
64
|
+
@data.debian_revision.should == "1"
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should provide access to the debian architecture name" do
|
68
|
+
@data.debian_arch.should == "all"
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should provide access to its license" do
|
72
|
+
@data.license.should == "(c) Matt 4evah"
|
73
|
+
end
|
74
|
+
|
75
|
+
it "should provide access to its install-time deps" do
|
76
|
+
@data.dependencies.should == :deps
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should provide access to its build-time deps" do
|
80
|
+
@data.build_dependencies.should == :deps
|
81
|
+
end
|
82
|
+
|
83
|
+
it "should provide access to its summary" do
|
84
|
+
@data.summary.should == "Matt's great Rails app"
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should provide access to its 'full_name' equivalent" do
|
88
|
+
@data.full_name.should == 'rails-app-1.0.8'
|
89
|
+
end
|
90
|
+
|
91
|
+
it "should provide access to its base_path" do
|
92
|
+
@data.base_path.should == 'base_path'
|
93
|
+
end
|
94
|
+
|
95
|
+
it "should provide the rakefile_location information so the rakefile can be generated in the right place" do
|
96
|
+
@data.rakefile_location.should == [:base_path, 'lib/tasks/dpkg-tools.rake']
|
97
|
+
end
|
98
|
+
|
99
|
+
it "should provide access to its mongrel starting port" do
|
100
|
+
@data.mongrel_cluster_start_port.should == '8000'
|
101
|
+
end
|
102
|
+
|
103
|
+
it "should provide access to the number of mongrels specified" do
|
104
|
+
@data.number_of_mongrels.should == 3
|
105
|
+
end
|
106
|
+
|
107
|
+
it "should provide access to an array of the port numbers to be used by the mongrels" do
|
108
|
+
@data.mongrel_ports.should == ['8000', '8001', '8002']
|
109
|
+
end
|
110
|
+
|
111
|
+
it "should provide access to the path of the resources dir in the gem" do
|
112
|
+
DpkgTools::Package::Rails::Data.resources_path.should == File.expand_path(File.dirname(__FILE__) + '/../../../../resources/rails')
|
113
|
+
end
|
114
|
+
|
115
|
+
it "should provide access to the target installation path for the app (i.e. /var/lib/blah)" do
|
116
|
+
@data.app_install_path.should == '/var/lib/rails-app'
|
117
|
+
end
|
118
|
+
|
119
|
+
it "should provide access to the server's main DNS name" do
|
120
|
+
@data.server_name.should == 'test.host'
|
121
|
+
end
|
122
|
+
|
123
|
+
it "should provide access to any DNS aliases the server will have" do
|
124
|
+
@data.server_aliases.should == ['www.test.host']
|
125
|
+
end
|
126
|
+
|
127
|
+
it "should provide access to the apps' databases" do
|
128
|
+
@data.database_configurations.should == @database_configurations
|
129
|
+
end
|
130
|
+
|
131
|
+
it "should provide the system user name for the app" do
|
132
|
+
@data.username.should == 'rails-app'
|
133
|
+
end
|
134
|
+
|
135
|
+
it "should provide the path to the cluster's PIDfile dir" do
|
136
|
+
@data.pidfile_dir_path.should == '/var/run/rails-app'
|
137
|
+
end
|
138
|
+
|
139
|
+
it "should provide the path to the logfile dirs" do
|
140
|
+
@data.logfile_path.should == '/var/log/rails-app'
|
141
|
+
end
|
142
|
+
|
143
|
+
it "should provide the path to the cluster's config root in /etc" do
|
144
|
+
@data.conf_dir_path.should == '/var/lib/rails-app/current/config'
|
145
|
+
end
|
146
|
+
|
147
|
+
it "should provide the capistrano application name" do
|
148
|
+
@data.application.should == @data.name
|
149
|
+
end
|
150
|
+
|
151
|
+
it "should provide the name of the user to ssh into servers as" do
|
152
|
+
@data.user.should == @data.name
|
153
|
+
end
|
154
|
+
|
155
|
+
it "should provide the path to the capistrano deploy_to location" do
|
156
|
+
@data.deploy_to.should == @data.app_install_path
|
157
|
+
end
|
158
|
+
|
159
|
+
it "should provide the path to the deployer's ssh keys dir in the package dir" do
|
160
|
+
@data.deployers_ssh_keys_dir.should == 'base_path/config/deployers_ssh_keys'
|
161
|
+
end
|
162
|
+
|
163
|
+
it "should provide access to the init script's path" do
|
164
|
+
@data.init_script_path.should == '/etc/init.d/rails-app'
|
165
|
+
end
|
166
|
+
|
167
|
+
it "should provide access to the app user's .ssh path" do
|
168
|
+
@data.dot_ssh_path.should == '/var/lib/rails-app/.ssh'
|
169
|
+
end
|
170
|
+
|
171
|
+
it "should provide access to the app user's ssh authorized_keys file" do
|
172
|
+
@data.authorized_keys_path.should == '/var/lib/rails-app/.ssh/authorized_keys'
|
173
|
+
end
|
174
|
+
|
175
|
+
it "should provide access to the raw hash for mongrel_cluster data" do
|
176
|
+
@data.mongrel_cluster_config_hash.should == @mongrel_cluster_config_data
|
177
|
+
end
|
178
|
+
end
|