cany 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,53 @@
1
+ require 'spec_helper'
2
+ require 'cany/recipes/bundler'
3
+ require 'cany/recipes/rails'
4
+
5
+
6
+ describe Cany::Dpkg::Builder do
7
+ let!(:dir) { Dir.mktmpdir }
8
+ after { FileUtils.remove_entry dir}
9
+ let(:spec) do
10
+ s = Cany::Specification.new do
11
+ name 'dpkg-creator-test'
12
+ version '0.1'
13
+ description 'Test Project'
14
+ maintainer_name 'Hans Otto'
15
+ maintainer_email 'hans.otto@example.org'
16
+ website 'http://example.org'
17
+ licence 'GPL-2+'
18
+ end
19
+ s.base_dir = dir
20
+ s
21
+ end
22
+ let(:builder) { Cany::Dpkg::Builder.new(spec) }
23
+
24
+ describe '#setup_recipes' do
25
+ it 'should always setup debhelper recipe' do
26
+ expect(Cany::Dpkg::DebHelperRecipe).to receive(:new).with(spec, nil)
27
+ builder.setup_recipes
28
+ end
29
+
30
+ it 'should instance any used recipes' do
31
+ spec.setup do
32
+ use :bundler
33
+ use :rails
34
+ end
35
+ expect(Cany::Dpkg::DebHelperRecipe).to receive(:new).ordered.with(spec, nil).and_call_original
36
+ expect(Cany::Recipes::Rails).to receive(:new).ordered.with(spec, kind_of(Cany::Dpkg::DebHelperRecipe)).and_call_original
37
+ expect(Cany::Recipes::Bundler).to receive(:new).ordered.with(spec, kind_of(Cany::Recipes::Rails)).and_call_original
38
+ builder.setup_recipes
39
+ end
40
+ end
41
+
42
+ describe '#run' do
43
+ it 'should setup recipes' do
44
+ expect(builder).to receive(:setup_recipes).and_call_original
45
+ builder.run 'clean'
46
+ end
47
+
48
+ it 'should call delegate the clean action to the loaded recipes' do
49
+ expect_any_instance_of(Cany::Dpkg::DebHelperRecipe).to receive(:clean)
50
+ builder.run 'clean'
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,221 @@
1
+ require 'spec_helper'
2
+
3
+ describe Cany::Dpkg::Creator do
4
+
5
+ context '#run' do
6
+ let!(:dir) { Dir.mktmpdir }
7
+ after { FileUtils.remove_entry dir}
8
+ let(:spec) do
9
+ s = Cany::Specification.new do
10
+ name 'dpkg-creator-test'
11
+ version '0.1'
12
+ description 'Test Project'
13
+ maintainer_name 'Hans Otto'
14
+ maintainer_email 'hans.otto@example.org'
15
+ website 'http://example.org'
16
+ licence 'GPL-2+'
17
+ end
18
+ s.base_dir = dir
19
+ s
20
+ end
21
+ let(:run) { Cany::Dpkg::Creator.new(spec).run *(@run_args || []) }
22
+
23
+ context 'debian directory' do
24
+ subject { File.join dir, 'debian' }
25
+
26
+ it do
27
+ run
28
+ expect(subject).to be_a_directory
29
+ end
30
+ end
31
+
32
+ context 'source format file' do
33
+ subject { File.join dir, 'debian', 'source', 'format' }
34
+
35
+ it do
36
+ run
37
+ expect(subject).to be_a_file
38
+ expect(subject).to have_the_content '3.0 (native)'
39
+ end
40
+ end
41
+
42
+ context 'compat file' do
43
+ subject { File.join dir, 'debian', 'compat' }
44
+
45
+ it do
46
+ run
47
+ expect(subject).to be_a_file
48
+ expect(subject).to have_the_content '8'
49
+ end
50
+ end
51
+
52
+ context 'control file' do
53
+ let(:filename) { File.join dir, 'debian', 'control' }
54
+ subject { DebControl::ControlFileBase.read filename }
55
+
56
+ it do
57
+ run
58
+ expect(subject.paragraphs.size).to eq 2
59
+ source = subject.paragraphs.first
60
+ binary = subject.paragraphs[1]
61
+
62
+ expect(source).to eq({
63
+ 'Source' => 'dpkg-creator-test',
64
+ 'Section' => 'ruby',
65
+ 'Priority' => 'optional',
66
+ 'Maintainer' => 'Hans Otto <hans.otto@example.org>',
67
+ 'Standards-Version' => '3.9.2',
68
+ 'Build-Depends' => 'debhelper (>= 7.0.50~), ruby, ruby-dev',
69
+ 'Homepage' => 'http://example.org'
70
+ })
71
+
72
+ expect(binary).to eq({
73
+ 'Package' => 'dpkg-creator-test',
74
+ 'Architecture' => 'any',
75
+ 'Depends' => '${shlibs:Depends}, ${misc:Depends}, ruby',
76
+ 'Description' => 'Test Project'
77
+ })
78
+ end
79
+
80
+ it 'use the specified ruby packages' do
81
+ @run_args = %w(--ruby-deb ruby2.0)
82
+ run
83
+ expect(subject.paragraphs.size).to eq 2
84
+ source = subject.paragraphs.first
85
+ binary = subject.paragraphs[1]
86
+
87
+ expect(source).to eq({
88
+ 'Source' => 'dpkg-creator-test',
89
+ 'Section' => 'ruby',
90
+ 'Priority' => 'optional',
91
+ 'Maintainer' => 'Hans Otto <hans.otto@example.org>',
92
+ 'Standards-Version' => '3.9.2',
93
+ 'Build-Depends' => 'debhelper (>= 7.0.50~), ruby2.0, ruby2.0-dev',
94
+ 'Homepage' => 'http://example.org'
95
+ })
96
+
97
+ expect(binary).to eq({
98
+ 'Package' => 'dpkg-creator-test',
99
+ 'Architecture' => 'any',
100
+ 'Depends' => '${shlibs:Depends}, ${misc:Depends}, ruby2.0',
101
+ 'Description' => 'Test Project'
102
+ })
103
+ end
104
+
105
+ it 'use the specified ruby' do
106
+ @run_args = %w(--ruby ruby2.0)
107
+ run
108
+ expect(subject.paragraphs.size).to eq 2
109
+ source = subject.paragraphs.first
110
+ binary = subject.paragraphs[1]
111
+
112
+ expect(source).to eq({
113
+ 'Source' => 'dpkg-creator-test',
114
+ 'Section' => 'ruby',
115
+ 'Priority' => 'optional',
116
+ 'Maintainer' => 'Hans Otto <hans.otto@example.org>',
117
+ 'Standards-Version' => '3.9.2',
118
+ 'Build-Depends' => 'debhelper (>= 7.0.50~), ruby2.0, ruby2.0-dev',
119
+ 'Homepage' => 'http://example.org'
120
+ })
121
+
122
+ expect(binary).to eq({
123
+ 'Package' => 'dpkg-creator-test',
124
+ 'Architecture' => 'any',
125
+ 'Depends' => '${shlibs:Depends}, ${misc:Depends}, ruby2.0',
126
+ 'Description' => 'Test Project'
127
+ })
128
+ end
129
+
130
+ it 'should add extra deps in specific gems are used' do
131
+ FileUtils.copy File.expand_path('../../fixtures/testgem.lock', __FILE__), File.join(dir, 'Gemfile.lock')
132
+ run
133
+ expect(subject.paragraphs.size).to eq 2
134
+ source =
135
+ binary = subject.paragraphs[1]
136
+ src_deps = subject.paragraphs.first['Build-Depends'].gsub(', ', ',').split(',')
137
+ bin_deps = subject.paragraphs[1]['Depends'].gsub(', ', ',').split(',')
138
+
139
+ expect(src_deps).to include('libpq-dev')
140
+ expect(bin_deps).to include('libpq5')
141
+ end
142
+ end
143
+
144
+ context 'copyright file' do
145
+ let(:filename) { File.join dir, 'debian', 'copyright' }
146
+ subject { DebControl::ControlFileBase.read filename }
147
+
148
+ it do
149
+ run
150
+ expect(subject.paragraphs.size).to eq 2
151
+
152
+ expect(subject.paragraphs.first).to eq({
153
+ 'Format' => 'http://dep.debian.net/deps/dep5',
154
+ 'Upstream-Name' => 'dpkg-creator-test',
155
+ })
156
+
157
+ expect(subject.paragraphs[1]).to eq({
158
+ 'Files' => '*',
159
+ 'Copyright' => "#{Time.now.year} Hans Otto",
160
+ 'Licence' => "GPL-2+\n[LICENCE TEXT]"
161
+ })
162
+ end
163
+ end
164
+
165
+ context 'rules file' do
166
+ let(:filename) { File.join dir, 'debian', 'rules' }
167
+ subject { File.read filename }
168
+
169
+ it do
170
+ run
171
+
172
+ expect(filename).to be_executable
173
+
174
+ expect(subject).to start_with '#!/usr/bin/make -f'
175
+ expect(subject).to include "export PATH := debian/bin:${PATH}\n"
176
+ expect(subject).to include "export GEM_PATH := debian/gems:${GEM_PATH}\n"
177
+ expect(subject).to include "\truby -S cany dpkg-builder $@"
178
+ expect(subject).to include "\truby -cS cany >/dev/null || ruby -S gem install --no-ri --no-rdoc --install-dir debian/gems --bindir debian/bin $${CANY_GEM:-cany}"
179
+ expect(subject).to include "override_dh_prep:"
180
+ end
181
+
182
+ it 'should use the selected interpreter' do
183
+ @run_args = '--ruby-exe', 'ruby1.9.1'
184
+ run
185
+
186
+ expect(filename).to be_executable
187
+
188
+ expect(subject).to start_with '#!/usr/bin/make -f'
189
+ expect(subject).to include "\truby1.9.1 -S cany dpkg-builder $@"
190
+ expect(subject).to include "\truby1.9.1 -cS cany >/dev/null || ruby1.9.1 -S gem install --no-ri --no-rdoc --install-dir debian/gems --bindir debian/bin $${CANY_GEM:-cany}"
191
+ end
192
+
193
+ it 'should use the current ruby' do
194
+ @run_args = '--ruby', 'ruby1.9.1'
195
+ run
196
+
197
+ expect(filename).to be_executable
198
+
199
+ expect(subject).to start_with '#!/usr/bin/make -f'
200
+ expect(subject).to include "\truby1.9.1 -S cany dpkg-builder $@"
201
+ expect(subject).to include "\truby1.9.1 -cS cany >/dev/null || ruby1.9.1 -S gem install --no-ri --no-rdoc --install-dir debian/gems --bindir debian/bin $${CANY_GEM:-cany}"
202
+ end
203
+ end
204
+
205
+ context 'changelog file' do
206
+ let(:filename) { File.join dir, 'debian', 'changelog' }
207
+ subject { File.read filename }
208
+
209
+ it do
210
+ Timecop.freeze(Time.new(2013, 8, 14, 1, 18, 51, 2)) do
211
+ run
212
+ end
213
+ expect(subject).to eq 'dpkg-creator-test (0.1-1) unstable; urgency=low
214
+
215
+ * Build with cany
216
+
217
+ -- Hans Otto <hans.otto@example.org> Wed, 14 Aug 2013 01:18:51 +0000'
218
+ end
219
+ end
220
+ end
221
+ end
File without changes
File without changes
@@ -0,0 +1,3 @@
1
+ Cany::Specification.new do
2
+ name 'single-test'
3
+ end
@@ -0,0 +1,10 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ pg (0.16.0)
5
+
6
+ PLATFORMS
7
+ ruby
8
+
9
+ DEPENDENCIES
10
+ pg
@@ -0,0 +1,34 @@
1
+ require 'bundler/setup'
2
+
3
+ require 'cany'
4
+ require 'deb_control'
5
+ require 'tmpdir'
6
+ require 'timecop'
7
+
8
+ Dir[File.expand_path('spec/support/**/*.rb')].each {|f| require f}
9
+
10
+ RSpec.configure do |config|
11
+ # ## Mock Framework
12
+ #
13
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
14
+ #
15
+ # config.mock_with :mocha
16
+ # config.mock_with :flexmock
17
+ # config.mock_with :rr
18
+
19
+ # Run specs in random order to surface order dependencies. If you find an
20
+ # order dependency and want to debug it, you can fix the order by providing
21
+ # the seed, which is printed after each run.
22
+ # --seed 1234
23
+ config.order = 'random'
24
+
25
+ config.expect_with :rspec do |c|
26
+ # Only allow expect syntax
27
+ c.syntax = :expect
28
+ end
29
+
30
+ config.before(:each) do
31
+ @executed_programs = []
32
+ allow_any_instance_of(Cany::Recipe).to receive(:exec) { |*args| @executed_programs << args }
33
+ end
34
+ end
@@ -0,0 +1,23 @@
1
+ RSpec::Matchers.define :be_a_directory do
2
+ match do |actual|
3
+ File.directory? actual.to_s
4
+ end
5
+ end
6
+
7
+ RSpec::Matchers.define :be_a_file do
8
+ match do |actual|
9
+ File.file? actual.to_s
10
+ end
11
+ end
12
+
13
+ RSpec::Matchers.define :have_the_content do |expected|
14
+ match do |actual|
15
+ File.read(actual.to_s) == expected
16
+ end
17
+ end
18
+
19
+ RSpec::Matchers.define :be_executable do
20
+ match do |actual|
21
+ File.executable? actual.to_s
22
+ end
23
+ end
metadata ADDED
@@ -0,0 +1,128 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cany
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Malte Swart
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-09-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Canning your ruby applications
56
+ email:
57
+ - mswart@devtation.de
58
+ executables:
59
+ - cany
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - .gitignore
64
+ - Gemfile
65
+ - LICENSE.txt
66
+ - README.md
67
+ - Rakefile
68
+ - bin/cany
69
+ - cany.gemspec
70
+ - lib/cany.rb
71
+ - lib/cany/dpkg.rb
72
+ - lib/cany/dpkg/builder.rb
73
+ - lib/cany/dpkg/creator.rb
74
+ - lib/cany/dpkg/deb_helper_recipe.rb
75
+ - lib/cany/recipe.rb
76
+ - lib/cany/recipes/bundler.rb
77
+ - lib/cany/recipes/rails.rb
78
+ - lib/cany/recipes/thin.rb
79
+ - lib/cany/recipes/web_server.rb
80
+ - lib/cany/specification.rb
81
+ - lib/cany/specification/dsl.rb
82
+ - lib/cany/version.rb
83
+ - spec/cany/specification_spec.rb
84
+ - spec/cany_spec.rb
85
+ - spec/dpkg/builder_spec.rb
86
+ - spec/dpkg/creator_spec.rb
87
+ - spec/fixtures/multiple/one.canspec
88
+ - spec/fixtures/multiple/two.canspec
89
+ - spec/fixtures/single/single.canspec
90
+ - spec/fixtures/testgem.lock
91
+ - spec/spec_helper.rb
92
+ - spec/support/file_matchers.rb
93
+ homepage: https://github.com/mswart/cany
94
+ licenses:
95
+ - MIT
96
+ metadata: {}
97
+ post_install_message:
98
+ rdoc_options: []
99
+ require_paths:
100
+ - lib
101
+ required_ruby_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - '>='
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ required_rubygems_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ requirements: []
112
+ rubyforge_project:
113
+ rubygems_version: 2.0.3
114
+ signing_key:
115
+ specification_version: 4
116
+ summary: Canning your ruby applications
117
+ test_files:
118
+ - spec/cany/specification_spec.rb
119
+ - spec/cany_spec.rb
120
+ - spec/dpkg/builder_spec.rb
121
+ - spec/dpkg/creator_spec.rb
122
+ - spec/fixtures/multiple/one.canspec
123
+ - spec/fixtures/multiple/two.canspec
124
+ - spec/fixtures/single/single.canspec
125
+ - spec/fixtures/testgem.lock
126
+ - spec/spec_helper.rb
127
+ - spec/support/file_matchers.rb
128
+ has_rdoc: