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,111 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
|
3
|
+
describe DpkgTools::Package::ControlFiles::Base, "writing control files out" do
|
4
|
+
it "should be able to make the target dir" do
|
5
|
+
Dir.expects(:mkdir).with('a_path/debian')
|
6
|
+
File.stubs(:exists?).with('a_path/debian').returns(false)
|
7
|
+
|
8
|
+
DpkgTools::Package::ControlFiles::Base.check_target_dir("a_path/debian")
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should be able to write a file in the debian dir" do
|
12
|
+
DpkgTools::Package::ControlFiles::Base.expects(:check_target_dir).with('a_path/debian')
|
13
|
+
mock_file = mock('Mock file')
|
14
|
+
mock_file.expects(:write).with('file contents')
|
15
|
+
File.expects(:open).with('a_path/debian/filename', 'w').yields(mock_file)
|
16
|
+
|
17
|
+
DpkgTools::Package::ControlFiles::Base.write('a_path/debian/filename', 'file contents')
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should be able to write an executable file in the debian dir" do
|
21
|
+
DpkgTools::Package::ControlFiles::Base.expects(:write).with('a_path/debian/rules', 'file contents')
|
22
|
+
File.expects(:chmod).with(0755, "a_path/debian/rules")
|
23
|
+
DpkgTools::Package::ControlFiles::Base.write_executable('a_path/debian/rules', 'file contents')
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should be able to return its filename" do
|
27
|
+
DpkgTools::Package::ControlFiles::Base.filename.should == 'base'
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should be able to return its formatter class" do
|
31
|
+
DpkgTools::Package::ControlFiles::Base.formatter_class.should == DpkgTools::Package::ControlFiles::BaseFormatter
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe DpkgTools::Package::ControlFiles::Base, "creating instances" do
|
36
|
+
it "should require a data and config object to be passed in" do
|
37
|
+
DpkgTools::Package::ControlFiles::Base.new(:data, :config).should be_an_instance_of(DpkgTools::Package::ControlFiles::Base)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should fail if no arguments are passed in" do
|
41
|
+
lambda { DpkgTools::Package::ControlFiles::Base.new }.should raise_error
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should fail if only one argument is passed in" do
|
45
|
+
lambda { DpkgTools::Package::ControlFiles::Base.new(:data) }.should raise_error
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe DpkgTools::Package::ControlFiles::Base, "instances" do
|
50
|
+
before(:each) do
|
51
|
+
@config = DpkgTools::Package::Config.new('name', '1.0', :base_path => '/a/path/to/package')
|
52
|
+
@formatter = mock('DpkgTools::Package::ControlFiles::BaseFormatter')
|
53
|
+
DpkgTools::Package::ControlFiles::BaseFormatter.expects(:new).with(anything).returns(@formatter)
|
54
|
+
@control_file = DpkgTools::Package::ControlFiles::Base.new(:data, @config)
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should use the class' value for filename" do
|
58
|
+
DpkgTools::Package::ControlFiles::Base.expects(:filename).returns(:class_filename)
|
59
|
+
@control_file.filename.should == :class_filename
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should be able to return its formatter class instance" do
|
63
|
+
@control_file.formatter.should == @formatter
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should be able to figure out where it should be written" do
|
67
|
+
@control_file.file_path.should == '/a/path/to/package/debian/base'
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should be able to specify whether to write itself out as an executable" do
|
71
|
+
@control_file.executable?.should be_false
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should be able to write itself out" do
|
75
|
+
@control_file.expects(:to_s).returns('file contents')
|
76
|
+
DpkgTools::Package::ControlFiles::Base.expects(:write).with('/a/path/to/package/debian/base', 'file contents')
|
77
|
+
|
78
|
+
@control_file.write
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should be able to create a string with the file contents in" do
|
82
|
+
@formatter.expects(:build).returns('file contents')
|
83
|
+
|
84
|
+
@control_file.to_s.should == 'file contents'
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should be able to tell that the existing control file is different to the one that this instance would generate" do
|
88
|
+
@control_file.expects(:to_s).returns('new file contents')
|
89
|
+
@control_file.stubs(:file_path).returns('/a/path/to/control_file')
|
90
|
+
File.expects(:exist?).with('/a/path/to/control_file').returns(true)
|
91
|
+
File.expects(:read).with('/a/path/to/control_file').returns('file contents')
|
92
|
+
|
93
|
+
@control_file.needs_reset?.should be_true
|
94
|
+
end
|
95
|
+
|
96
|
+
it "should be able to tell that the existing control file is the same as the one that this instance would generate" do
|
97
|
+
@control_file.expects(:to_s).returns('file contents')
|
98
|
+
@control_file.stubs(:file_path).returns('/a/path/to/control_file')
|
99
|
+
File.expects(:exist?).with('/a/path/to/control_file').returns(true)
|
100
|
+
File.expects(:read).with('/a/path/to/control_file').returns('file contents')
|
101
|
+
|
102
|
+
@control_file.needs_reset?.should be_false
|
103
|
+
end
|
104
|
+
|
105
|
+
it "should know that if a control file is missing then a reset is needed by default" do
|
106
|
+
@control_file.expects(:file_path).returns('/a/path/to/control_file')
|
107
|
+
File.expects(:exist?).with('/a/path/to/control_file').returns(false)
|
108
|
+
|
109
|
+
@control_file.needs_reset?.should be_true
|
110
|
+
end
|
111
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
|
3
|
+
describe DpkgTools::Package::ControlFiles::Changelog, "generating the debian/control file" do
|
4
|
+
it "should return the correct filename" do
|
5
|
+
DpkgTools::Package::ControlFiles::Changelog.filename.should == 'changelog'
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should return the correct formatter class" do
|
9
|
+
DpkgTools::Package::ControlFiles::Changelog.formatter_class.
|
10
|
+
should == DpkgTools::Package::ControlFiles::ChangelogFormatter
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe DpkgTools::Package::ControlFiles::ChangelogFormatter, "Can generate a debian/copyright file" do
|
15
|
+
it "should grab the license_file from the metadata object" do
|
16
|
+
metadata = mock('package metadata object')
|
17
|
+
metadata.expects(:changelog).returns("Changelog file")
|
18
|
+
|
19
|
+
formatter = DpkgTools::Package::ControlFiles::ChangelogFormatter.new(metadata)
|
20
|
+
formatter.build.should == "Changelog file"
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,131 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
|
3
|
+
describe "generating the debian/control file" do
|
4
|
+
describe DpkgTools::Package::ControlFiles::Control do
|
5
|
+
it "should return the correct filename" do
|
6
|
+
DpkgTools::Package::ControlFiles::Control.filename.should == 'control'
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should return the correct formatter class" do
|
10
|
+
DpkgTools::Package::ControlFiles::Control.formatter_class.
|
11
|
+
should == DpkgTools::Package::ControlFiles::ControlFormatter
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "instances" do
|
15
|
+
before(:each) do
|
16
|
+
stub_requirement = stub('stub Gem::Requirement', :as_list => [">= 0.0.0"])
|
17
|
+
@mock_dep_list = [stub('stub Gem::Dependency', :name => 'whatagem', :version_requirements => stub_requirement)]
|
18
|
+
@stub_data = stub('stub DpkgTools::Package::Data',
|
19
|
+
:build_dependencies => [{:name => "build_dep", :requirements => [">= 0.9.4-1"]}],
|
20
|
+
:dependencies => [{:name => "dep", :requirements => [">= 0.9.4-1"]}],
|
21
|
+
:summary => "Test gem for testing", :debian_arch => 'i386')
|
22
|
+
@stub_config = DpkgTools::Package::Config.new('gem-name', '1.0.8', :suffix => 'rubygem')
|
23
|
+
|
24
|
+
@control_file = DpkgTools::Package::ControlFiles::Control.new(@stub_data, @stub_config)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should be able to return the Source: line" do
|
28
|
+
@control_file.source.should == @stub_config.package_name
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should be able to return the Maintainer: line" do
|
32
|
+
@control_file.maintainer.should == ["Matt Patterson", "matt@reprocessed.org"]
|
33
|
+
end
|
34
|
+
it "should be able to generate Build-Depends: line" do
|
35
|
+
@control_file.build_depends.should == @stub_data.build_dependencies
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should be able to generate the Standards-Version: line" do
|
39
|
+
@control_file.standards_version.should == DpkgTools::Package.standards_version
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should be able to generate the Package: line" do
|
43
|
+
@control_file.package.should == @stub_config.package_name
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should be able to generate the Architecture: line" do
|
47
|
+
@control_file.architecture.should == "i386"
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should be able to generate the Depends: line" do
|
51
|
+
@control_file.depends.should == @stub_data.dependencies
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should be able to generate the Essential: line" do
|
55
|
+
@control_file.essential.should == "no"
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should be able to generate the Description: line" do
|
59
|
+
@control_file.description.should == "Test gem for testing"
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe DpkgTools::Package::ControlFiles::ControlFormatter, "instances" do
|
65
|
+
before(:each) do
|
66
|
+
@metadata = stub("DpkgTools::Package::Blah::ControlFiles::Control", :source => 'source-package-name',
|
67
|
+
:package => 'binary-package-name', :maintainer => ["Matt Patterson", "matt@reprocessed.org"])
|
68
|
+
@formatter = DpkgTools::Package::ControlFiles::ControlFormatter.new(@metadata)
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should be able to return a list of source paragraph fields" do
|
72
|
+
@formatter.source_field_names.should be_an_instance_of(Array)
|
73
|
+
end
|
74
|
+
|
75
|
+
it "should be able to return a list of binary paragraph fields" do
|
76
|
+
@formatter.binary_field_names.should be_an_instance_of(Array)
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should be able to map field_names symbols to the .deb format version" do
|
80
|
+
@formatter.field_names_map.should be_an_instance_of(Hash)
|
81
|
+
end
|
82
|
+
|
83
|
+
it "should be able to correctly construct a Maintainer line" do
|
84
|
+
@formatter.maintainer.should == "Maintainer: Matt Patterson <matt@reprocessed.org>"
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should be able to turn a list of deps into a correctly formatted string" do
|
88
|
+
deps = [{:name => "a-dependency", :requirements => [">= 0.0.0-1"]}, {:name => "another-dep", :requirements => [">= 0", "<= 1"]}]
|
89
|
+
@formatter.send(:deps_string, deps).should == "a-dependency (>= 0.0.0-1), another-dep (>= 0) (<= 1)"
|
90
|
+
end
|
91
|
+
|
92
|
+
describe "handling dependencies lines" do
|
93
|
+
it "should iterate across the control file field names and insert any lines represented by methods in the metadata object" do
|
94
|
+
metadata = stub('Gem::ControlFilesData::Control instance', :source => 'source-package-name', :package => 'binary-package-name')
|
95
|
+
|
96
|
+
formatter = DpkgTools::Package::ControlFiles::ControlFormatter.new(metadata)
|
97
|
+
formatter.build.should == "Source: source-package-name\n\nPackage: binary-package-name\n"
|
98
|
+
end
|
99
|
+
|
100
|
+
it "should be able to correctly construct a dependencies line" do
|
101
|
+
metadata = stub('package metadata object', :depends => [{:name => "dependency", :requirements => [">= 1.0.0-1"]}])
|
102
|
+
|
103
|
+
formatter = DpkgTools::Package::ControlFiles::ControlFormatter.new(metadata)
|
104
|
+
formatter.send(:depends_line, :depends).should == "Depends: dependency (>= 1.0.0-1)"
|
105
|
+
end
|
106
|
+
|
107
|
+
it "should be able to correctly construct a dependencies line which has no requirements" do
|
108
|
+
metadata = stub('package metadata object', :depends => [{:name => "dependency", :requirements => []}])
|
109
|
+
|
110
|
+
formatter = DpkgTools::Package::ControlFiles::ControlFormatter.new(metadata)
|
111
|
+
formatter.send(:depends_line, :depends).should == "Depends: dependency"
|
112
|
+
end
|
113
|
+
|
114
|
+
it "should be able to correctly construct a dependencies line which has requirements unset" do
|
115
|
+
metadata = stub('package metadata object', :depends => [{:name => "dependency"}])
|
116
|
+
|
117
|
+
formatter = DpkgTools::Package::ControlFiles::ControlFormatter.new(metadata)
|
118
|
+
formatter.send(:depends_line, :depends).should == "Depends: dependency"
|
119
|
+
end
|
120
|
+
|
121
|
+
it "should be able to handle fields which need special processing by calling the local method and handing off the metadata to that" do
|
122
|
+
metadata = stub('package metadata object', :depends => [{:name => "dependency", :requirements => [">= 1.0.0-1"]}])
|
123
|
+
formatter = DpkgTools::Package::ControlFiles::ControlFormatter.new(metadata)
|
124
|
+
|
125
|
+
formatter.expects(:depends_line).with(:depends).returns("Here is a depends line")
|
126
|
+
|
127
|
+
formatter.build.should == "\nHere is a depends line\n"
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
|
3
|
+
describe DpkgTools::Package::ControlFiles::Copyright, "generating the debian/control file" do
|
4
|
+
it "should return the correct filename" do
|
5
|
+
DpkgTools::Package::ControlFiles::Copyright.filename.should == 'copyright'
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should return the correct formatter class" do
|
9
|
+
DpkgTools::Package::ControlFiles::Copyright.formatter_class.
|
10
|
+
should == DpkgTools::Package::ControlFiles::CopyrightFormatter
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should be able to locate and return the app's license" do
|
14
|
+
stub_data = stub('stub DpkgTools::Package::Data', :license => "(c) Matt Patterson 2007, All rights reserved")
|
15
|
+
metadata = DpkgTools::Package::ControlFiles::Copyright.new(stub_data, :config)
|
16
|
+
|
17
|
+
metadata.license_file.should == "(c) Matt Patterson 2007, All rights reserved"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe DpkgTools::Package::ControlFiles::CopyrightFormatter, "Can generate a debian/copyright file" do
|
22
|
+
it "should grab the license_file from the metadata object" do
|
23
|
+
metadata = mock('package metadata object')
|
24
|
+
metadata.expects(:license_file).returns("License file")
|
25
|
+
|
26
|
+
formatter = DpkgTools::Package::ControlFiles::CopyrightFormatter.new(metadata)
|
27
|
+
formatter.build.should == "License file"
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
|
3
|
+
describe DpkgTools::Package::ControlFiles::Rakefile, "generating the debian/control file" do
|
4
|
+
it "should return the correct filename" do
|
5
|
+
DpkgTools::Package::ControlFiles::Rakefile.filename.should be_nil
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should return the correct formatter class" do
|
9
|
+
DpkgTools::Package::ControlFiles::Rakefile.formatter_class.
|
10
|
+
should == DpkgTools::Package::ControlFiles::RakefileFormatter
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe DpkgTools::Package::ControlFiles::Rakefile, "instances" do
|
15
|
+
it "should generate the correct path" do
|
16
|
+
data = mock('DpkgTools::Package::Data')
|
17
|
+
data.expects(:rakefile_location).returns([:base_path, 'Rakefile'])
|
18
|
+
config = mock('DpkgTools::Package::Config')
|
19
|
+
config.expects(:base_path).returns('/a/path/to')
|
20
|
+
|
21
|
+
control_file = DpkgTools::Package::ControlFiles::Rakefile.new(data, config)
|
22
|
+
control_file.file_path.should == '/a/path/to/Rakefile'
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe DpkgTools::Package::ControlFiles::RakefileFormatter, "Can generate a debian/copyright file" do
|
27
|
+
before(:each) do
|
28
|
+
@metadata = mock('package metadata object')
|
29
|
+
@metadata.expects(:rakefile).returns("Rakefile")
|
30
|
+
|
31
|
+
@formatter = DpkgTools::Package::ControlFiles::RakefileFormatter.new(@metadata)
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should grab the license_file from the metadata object" do
|
35
|
+
@formatter.build.should == "Rakefile"
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
|
3
|
+
describe DpkgTools::Package::ControlFiles::Rules, "generating the debian/control file" do
|
4
|
+
it "should return the correct filename" do
|
5
|
+
DpkgTools::Package::ControlFiles::Rules.filename.should == 'rules'
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should be an executable file" do
|
9
|
+
DpkgTools::Package::ControlFiles::Rules.new(:data, :config).executable?.should be_true
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should return the correct formatter class" do
|
13
|
+
DpkgTools::Package::ControlFiles::Rules.formatter_class.
|
14
|
+
should == DpkgTools::Package::ControlFiles::RulesFormatter
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
describe DpkgTools::Package::ControlFiles, ".classes" do
|
4
|
+
it "should return the control file classes in an array" do
|
5
|
+
DpkgTools::Package::ControlFiles.classes.
|
6
|
+
should == [DpkgTools::Package::ControlFiles::Changelog,
|
7
|
+
DpkgTools::Package::ControlFiles::Control,
|
8
|
+
DpkgTools::Package::ControlFiles::Copyright,
|
9
|
+
DpkgTools::Package::ControlFiles::Rakefile,
|
10
|
+
DpkgTools::Package::ControlFiles::Rules]
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,115 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
describe DpkgTools::Package::Data, "instances" do
|
4
|
+
before(:each) do
|
5
|
+
@data = DpkgTools::Package::Data.new
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should provide public access to a binding object of their context" do
|
9
|
+
@data.binding.should be_an_instance_of(Binding)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should provide access to the path of the resources dir in the gem" do
|
13
|
+
DpkgTools::Package::Data.resources_path.should == File.expand_path(File.dirname(__FILE__) + '/../../../resources/data')
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should provide access to the name of the resources subdir in the gem" do
|
17
|
+
DpkgTools::Package::Data.resources_dirname.should == 'data'
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should provide access to the resources_path class method on instances" do
|
21
|
+
@data.resources_path.should == DpkgTools::Package::Data.resources_path
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should be able to say that it's an architecture-independent package when it is" do
|
25
|
+
@data.stubs(:debian_arch).returns('all')
|
26
|
+
@data.architecture_independent?.should be_true
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should be able to say that it isn't an architecture-independent package when it isn't" do
|
30
|
+
@data.stubs(:debian_arch).returns('i386')
|
31
|
+
@data.architecture_independent?.should be_false
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe DpkgTools::Package::Data::YamlConfigHelpers do
|
36
|
+
before(:each) do
|
37
|
+
@module = Module.new
|
38
|
+
@module.extend(DpkgTools::Package::Data::YamlConfigHelpers)
|
39
|
+
end
|
40
|
+
|
41
|
+
describe ".load_package_data" do
|
42
|
+
it "should be able to figure out the path to a given .yml file" do
|
43
|
+
@module.package_data_file_path('base_path', 'deb.yml').should == 'base_path/deb.yml'
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should be able to read in the config/*.yml file" do
|
47
|
+
File.expects(:exist?).with('base_path/deb.yml').returns(true)
|
48
|
+
YAML.expects(:load_file).with('base_path/deb.yml').returns({"name" => 'rails-app'})
|
49
|
+
@module.load_package_data('base_path', 'deb.yml').should == {"name" => 'rails-app'}
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe ".process_dependencies" do
|
54
|
+
it "should report the base deps if the YAML says no deps at all" do
|
55
|
+
fixture_data = {'name' => 'rails-app', 'version' => '1.0.8', 'license' => '(c) Matt 4evah'}
|
56
|
+
|
57
|
+
@module.expects(:base_gem_deps).returns([:dep_the_first])
|
58
|
+
@module.expects(:base_package_deps).returns([:dep_the_other])
|
59
|
+
@module.process_dependencies(fixture_data).
|
60
|
+
should have_the_same_contents_as([:dep_the_first, :dep_the_other])
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should report base deps plus gem deps if they're specified" do
|
64
|
+
fixture_data = {'dependencies' => {'gem' => ['rspec' => ['>= 1.0.8']]}}
|
65
|
+
|
66
|
+
@module.process_dependencies(fixture_data).
|
67
|
+
should include({:name => 'rspec-rubygem', :requirements => ['>= 1.0.8-1']})
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should report base deps plus package deps if they're specified" do
|
71
|
+
fixture_data = {'dependencies' => {'package' => ['rspec' => ['>= 1.0.8']]}}
|
72
|
+
|
73
|
+
@module.process_dependencies(fixture_data).
|
74
|
+
should include({:name => 'rspec', :requirements => ['>= 1.0.8']})
|
75
|
+
end
|
76
|
+
|
77
|
+
it "should be able to report base deps plus any other deps..." do
|
78
|
+
fixture_data = {'dependencies' => {'gem' => ['rspec' => ['>= 1.0.8']],
|
79
|
+
'package' => ['rspec' => ['>= 1.0.8']]}}
|
80
|
+
deps = @module.process_dependencies(fixture_data)
|
81
|
+
deps.should include({:name => 'rspec-rubygem', :requirements => ['>= 1.0.8-1']})
|
82
|
+
deps.should include({:name => 'rspec', :requirements => ['>= 1.0.8']})
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should be able to cope with deps whose version requirements are specified by a single string" do
|
86
|
+
fixture_data = {'dependencies' => {'gem' => ['rspec' => '>= 1.0.8']}}
|
87
|
+
|
88
|
+
@module.process_dependencies(fixture_data).
|
89
|
+
should include({:name => 'rspec-rubygem', :requirements => ['>= 1.0.8-1']})
|
90
|
+
end
|
91
|
+
|
92
|
+
it "should raise an appropriate error if the dependencies collection is not a Hash (YAML collection)" do
|
93
|
+
fixture_data = {'dependencies' => 'string'}
|
94
|
+
|
95
|
+
lambda { @module.process_dependencies(fixture_data) }.
|
96
|
+
should raise_error(DpkgTools::Package::DebYAMLParseError)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
describe @module, ".process_dependencies_by_type" do
|
101
|
+
it "should raise an appropriate error if the dependencies gem sequence isn't a sequence" do
|
102
|
+
fixture_data = {'gem' => 'string'}
|
103
|
+
|
104
|
+
lambda { @module.process_dependencies_by_type(fixture_data, 'gem') }.
|
105
|
+
should raise_error(DpkgTools::Package::DebYAMLParseError)
|
106
|
+
end
|
107
|
+
|
108
|
+
it "should raise an appropriate error if one of package dependencies version requirements list isn't a list or a string..." do
|
109
|
+
fixture_data = {'package' => ['rspec' => {'>= 1.0.8' => 'blah'}]}
|
110
|
+
|
111
|
+
lambda { @module.process_dependencies_by_type(fixture_data, 'package') }.
|
112
|
+
should raise_error(DpkgTools::Package::DebYAMLParseError)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|