fpm-cookery 0.19.0 → 0.20.0

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.
@@ -10,23 +10,6 @@ describe 'Maintainer' do
10
10
 
11
11
  let(:maintainer) { klass.new(recipe, config) }
12
12
 
13
- def with_shellout_stub(opts = {}, &spec)
14
- callable = lambda do |key|
15
- return if opts[:nil]
16
-
17
- case key
18
- when 'user.name'
19
- 'John Doe'
20
- when 'user.email'
21
- 'john@example.com'
22
- else
23
- raise "Invalid key: #{key}"
24
- end
25
- end
26
-
27
- FPM::Cookery::Shellout.stub(:git_config_get, callable, &spec)
28
- end
29
-
30
13
  def with_env_stub(env)
31
14
  old_env = ENV.to_hash
32
15
  env.each do |key, value|
@@ -37,54 +20,51 @@ describe 'Maintainer' do
37
20
  ENV.replace(old_env)
38
21
  end
39
22
 
23
+ before do
24
+ allow(FPM::Cookery::Shellout).to receive(:git_config_get).with('user.name').and_return('John Doe')
25
+ allow(FPM::Cookery::Shellout).to receive(:git_config_get).with('user.email').and_return('john@example.com')
26
+ end
27
+
40
28
  describe '#to_s' do
41
29
  context 'with maintainer set in recipe' do
42
30
  it 'returns the recipe maintainer' do
43
- with_shellout_stub do
44
- recipe.maintainer = 'Foo <bar@example.com>'
45
-
46
- maintainer.to_s.must_equal 'Foo <bar@example.com>'
47
- end
31
+ recipe.maintainer = 'Foo <bar@example.com>'
32
+ expect(maintainer.to_s).to eq('Foo <bar@example.com>')
48
33
  end
49
34
  end
50
35
 
51
36
  context 'with maintainer set in config' do
52
37
  it 'returns the config maintainer' do
53
- with_shellout_stub do
54
- config[:maintainer] = 'Foo <bar@example.com>'
38
+ config[:maintainer] = 'Foo <bar@example.com>'
55
39
 
56
- maintainer.to_s.must_equal 'Foo <bar@example.com>'
57
- end
40
+ expect(maintainer.to_s).to eq('Foo <bar@example.com>')
58
41
  end
59
42
  end
60
43
 
61
44
  context 'with maintainer in config and recipe' do
62
45
  it 'returns the config maintainer' do
63
- with_shellout_stub do
64
- recipe.maintainer = 'Foo <bar@example.com>'
65
- config[:maintainer] = 'Jane Doe <jane@example.com>'
46
+ recipe.maintainer = 'Foo <bar@example.com>'
47
+ config[:maintainer] = 'Jane Doe <jane@example.com>'
66
48
 
67
- maintainer.to_s.must_equal 'Jane Doe <jane@example.com>'
68
- end
49
+ expect(maintainer.to_s).to eq('Jane Doe <jane@example.com>')
69
50
  end
70
51
  end
71
52
 
72
53
  context 'without any maintainer set' do
73
54
  it 'returns the maintainer from git' do
74
- with_shellout_stub do
75
- maintainer.to_s.must_equal 'John Doe <john@example.com>'
76
- end
55
+ expect(maintainer.to_s).to eq('John Doe <john@example.com>')
77
56
  end
78
57
  end
79
58
 
80
59
  context 'without valid git data' do
60
+ before do
61
+ allow(FPM::Cookery::Shellout).to receive(:git_config_get).and_return(nil)
62
+ allow(Socket).to receive(:gethostname).and_return('hostname')
63
+ end
64
+
81
65
  it 'returns a default maintainer' do
82
- Socket.stub(:gethostname, lambda { 'hostname' }) do
83
- with_shellout_stub(:nil => true) do
84
- with_env_stub('USER' => 'john') do
85
- maintainer.to_s.must_equal '<john@hostname>'
86
- end
87
- end
66
+ with_env_stub('USER' => 'john') do
67
+ expect(maintainer.to_s).to eq('<john@hostname>')
88
68
  end
89
69
  end
90
70
  end
@@ -92,11 +72,9 @@ describe 'Maintainer' do
92
72
 
93
73
  describe '#to_str' do
94
74
  it 'converts the maintainer object to a string' do
95
- with_shellout_stub do
96
- recipe.maintainer = 'Foo <bar@example.com>'
75
+ recipe.maintainer = 'Foo <bar@example.com>'
97
76
 
98
- maintainer.to_str.must_equal 'Foo <bar@example.com>'
99
- end
77
+ expect(maintainer.to_str).to eq('Foo <bar@example.com>')
100
78
  end
101
79
  end
102
80
  end
data/spec/package_spec.rb CHANGED
@@ -55,107 +55,111 @@ describe 'Package' do
55
55
 
56
56
  describe 'fpm package object initialization' do
57
57
  it 'sets name' do
58
- package.fpm.name.must_equal 'foo'
58
+ expect(package.fpm.name).to eq('foo')
59
59
  end
60
60
 
61
61
  it 'sets url' do
62
- package.fpm.url.must_equal 'http://example.com'
62
+ expect(package.fpm.url).to eq('http://example.com')
63
63
  end
64
64
 
65
65
  it 'sets category' do
66
- package.fpm.category.must_equal 'langs'
66
+ expect(package.fpm.category).to eq('langs')
67
67
  end
68
68
 
69
69
  context 'without section set' do
70
70
  it 'sets category to "optional"' do
71
71
  recipe.instance_variable_set(:@section, nil)
72
72
 
73
- package.fpm.category.must_equal 'optional'
73
+ expect(package.fpm.category).to eq('optional')
74
74
  end
75
75
  end
76
76
 
77
77
  it 'sets the description' do
78
- package.fpm.description.must_equal 'a test package'
78
+ expect(package.fpm.description).to eq('a test package')
79
79
  end
80
80
 
81
81
  it 'sets the architecture' do
82
- package.fpm.architecture.must_equal 'all'
82
+ expect(package.fpm.architecture).to eq('all')
83
83
  end
84
84
 
85
85
  it 'sets the dependencies' do
86
- package.fpm.dependencies.must_equal ['ab', 'c']
86
+ expect(package.fpm.dependencies).to eq(['ab', 'c'])
87
87
  end
88
88
 
89
89
  it 'sets the conflicts' do
90
- package.fpm.conflicts.must_equal ['xz', 'y']
90
+ expect(package.fpm.conflicts).to eq(['xz', 'y'])
91
91
  end
92
92
 
93
93
  it 'sets the provides' do
94
- package.fpm.provides.must_equal ['foo-package']
94
+ expect(package.fpm.provides).to eq(['foo-package'])
95
95
  end
96
96
 
97
97
  it 'sets the replaces' do
98
- package.fpm.replaces.must_equal ['foo-old']
98
+ expect(package.fpm.replaces).to eq(['foo-old'])
99
99
  end
100
100
 
101
101
  it 'sets the config_files' do
102
- package.fpm.config_files.must_equal ['/etc/foo.conf']
102
+ expect(package.fpm.config_files).to eq(['/etc/foo.conf'])
103
103
  end
104
104
 
105
105
  it 'sets the directories' do
106
- package.fpm.directories.must_equal ['/var/lib/foo', '/var/cache/foo']
106
+ expect(package.fpm.directories).to eq(['/var/lib/foo', '/var/cache/foo'])
107
107
  end
108
108
 
109
109
  describe 'attributes' do
110
110
  let(:attributes) { package.fpm.attributes }
111
111
 
112
112
  it 'sets deb_compression' do
113
- attributes[:deb_compression].must_equal 'gz'
113
+ expect(attributes[:deb_compression]).to eq('gz')
114
114
  end
115
115
 
116
116
  it 'sets deb_user' do
117
- attributes[:deb_user].must_equal 'root'
117
+ expect(attributes[:deb_user]).to eq('root')
118
118
  end
119
119
 
120
120
  it 'sets deb_group' do
121
- attributes[:deb_group].must_equal 'root'
121
+ expect(attributes[:deb_group]).to eq('root')
122
122
  end
123
123
 
124
124
  it 'sets rpm_compression' do
125
- attributes[:rpm_compression].must_equal 'gzip'
125
+ expect(attributes[:rpm_compression]).to eq('gzip')
126
126
  end
127
127
 
128
128
  it 'sets rpm_digest' do
129
- attributes[:rpm_digest].must_equal 'md5'
129
+ expect(attributes[:rpm_digest]).to eq('md5')
130
130
  end
131
131
 
132
132
  it 'sets rpm_user' do
133
- attributes[:rpm_user].must_equal 'root'
133
+ expect(attributes[:rpm_user]).to eq('root')
134
134
  end
135
135
 
136
136
  it 'sets rpm_group' do
137
- attributes[:rpm_group].must_equal 'root'
137
+ expect(attributes[:rpm_group]).to eq('root')
138
138
  end
139
139
 
140
140
  it 'sets rpm_defattrfile' do
141
- attributes[:rpm_defattrfile].must_equal '-'
141
+ expect(attributes[:rpm_defattrfile]).to eq('-')
142
142
  end
143
143
 
144
144
  it 'sets rpm_defattrdir' do
145
- attributes[:rpm_defattrdir].must_equal '-'
145
+ expect(attributes[:rpm_defattrdir]).to eq('-')
146
146
  end
147
147
 
148
148
  it 'sets excludes' do
149
- attributes[:excludes].must_equal []
149
+ expect(attributes[:excludes]).to eq([])
150
+ end
151
+
152
+ it 'sets rpm_auto_add_directories?' do
153
+ expect(attributes[:rpm_auto_add_directories?]).to eq(true)
150
154
  end
151
155
  end
152
156
 
153
157
  it 'calls the package_setup method' do
154
- package.test_package_setup_run.must_equal true
158
+ expect(package.test_package_setup_run).to eq(true)
155
159
  end
156
160
 
157
161
  it 'calls the package_input method' do
158
- package.test_package_input_run.must_equal true
162
+ expect(package.test_package_input_run).to eq(true)
159
163
  end
160
164
 
161
165
  context 'without package_input method defined' do
@@ -167,7 +171,9 @@ describe 'Package' do
167
171
  end
168
172
 
169
173
  it 'raises a MethodNotImplemented error' do
170
- proc { package_bare }.must_raise FPM::Cookery::Error::MethodNotImplemented
174
+ expect {
175
+ package_bare
176
+ }.to raise_error(FPM::Cookery::Error::MethodNotImplemented)
171
177
  end
172
178
  end
173
179
 
@@ -180,7 +186,9 @@ describe 'Package' do
180
186
  end
181
187
 
182
188
  it 'raises a MethodNotImplemented error' do
183
- proc { package_bare }.must_raise FPM::Cookery::Error::MethodNotImplemented
189
+ expect {
190
+ package_bare
191
+ }.to raise_error(FPM::Cookery::Error::MethodNotImplemented)
184
192
  end
185
193
  end
186
194
  end
@@ -3,7 +3,7 @@ require 'fpm/cookery/package/version'
3
3
  require 'ostruct'
4
4
 
5
5
  describe 'Version' do
6
- def target; 'deb'; end
6
+ let(:target) { 'deb' }
7
7
 
8
8
  let(:klass) { FPM::Cookery::Package::Version }
9
9
 
@@ -15,23 +15,23 @@ describe 'Version' do
15
15
  describe '#vendor_delimiter' do
16
16
  context 'with target deb' do
17
17
  it 'returns "+"' do
18
- version.vendor_delimiter.must_equal '+'
18
+ expect(version.vendor_delimiter).to eq('+')
19
19
  end
20
20
  end
21
21
 
22
22
  context 'with target rpm' do
23
- def target; 'rpm'; end
23
+ let(:target) { 'rpm' }
24
24
 
25
25
  it 'returns "."' do
26
- version.vendor_delimiter.must_equal '.'
26
+ expect(version.vendor_delimiter).to eq('.')
27
27
  end
28
28
  end
29
29
 
30
30
  context 'with unknown target' do
31
- def target; '_foo_'; end
31
+ let(:target) { '_foo_' }
32
32
 
33
33
  it 'returns "-"' do
34
- version.vendor_delimiter.must_equal '-'
34
+ expect(version.vendor_delimiter).to eq('-')
35
35
  end
36
36
  end
37
37
  end
@@ -41,7 +41,7 @@ describe 'Version' do
41
41
  it 'returns the config.vendor value' do
42
42
  config[:vendor] = 'foo'
43
43
 
44
- version.vendor.must_equal 'foo'
44
+ expect(version.vendor).to eq('foo')
45
45
  end
46
46
  end
47
47
 
@@ -49,7 +49,7 @@ describe 'Version' do
49
49
  it 'returns the recipe.vendor value' do
50
50
  recipe.vendor = 'bar'
51
51
 
52
- version.vendor.must_equal 'bar'
52
+ expect(version.vendor).to eq('bar')
53
53
  end
54
54
  end
55
55
 
@@ -58,7 +58,7 @@ describe 'Version' do
58
58
  config[:vendor] = 'foo'
59
59
  recipe.vendor = 'bar'
60
60
 
61
- version.vendor.must_equal 'foo'
61
+ expect(version.vendor).to eq('foo')
62
62
  end
63
63
  end
64
64
  end
@@ -67,7 +67,7 @@ describe 'Version' do
67
67
  it 'returns the recipe.revision value' do
68
68
  recipe.revision = 24
69
69
 
70
- version.revision.must_equal 24
70
+ expect(version.revision).to eq(24)
71
71
  end
72
72
  end
73
73
 
@@ -75,14 +75,14 @@ describe 'Version' do
75
75
  it 'returns the version epoch' do
76
76
  recipe.version = '4:1.2.3'
77
77
 
78
- version.epoch.must_equal '4'
78
+ expect(version.epoch).to eq('4')
79
79
  end
80
80
 
81
81
  context 'without epoch' do
82
82
  it 'returns nil' do
83
83
  recipe.version = '1.2.3'
84
84
 
85
- version.epoch.must_equal nil
85
+ expect(version.epoch).to eq(nil)
86
86
  end
87
87
  end
88
88
  end
@@ -93,18 +93,18 @@ describe 'Version' do
93
93
  recipe.vendor = 'testing1'
94
94
  recipe.revision = 5
95
95
 
96
- version.to_s.must_equal '2.1.3-5+testing1'
96
+ expect(version.to_s).to eq('2.1.3-5+testing1')
97
97
  end
98
98
 
99
99
  context 'with target rpm' do
100
- def target; 'rpm'; end
100
+ let(:target) { 'rpm' }
101
101
 
102
102
  it 'returns a string representation of the version' do
103
103
  recipe.version = '2.1.3'
104
104
  recipe.vendor = 'testing1'
105
105
  recipe.revision = 5
106
106
 
107
- version.to_s.must_equal '2.1.3-5.testing1'
107
+ expect(version.to_s).to eq('2.1.3-5.testing1')
108
108
  end
109
109
  end
110
110
 
@@ -113,31 +113,31 @@ describe 'Version' do
113
113
  recipe.version = '2.1.3'
114
114
  recipe.revision = 5
115
115
 
116
- version.to_s.must_equal '2.1.3-5'
116
+ expect(version.to_s).to eq('2.1.3-5')
117
117
  end
118
118
 
119
119
  context 'with target rpm' do
120
- def target; 'rpm'; end
120
+ let(:target) { 'rpm' }
121
121
 
122
122
  it 'returns a string representation of the version' do
123
123
  recipe.version = '2.1.3'
124
124
  recipe.revision = 5
125
125
 
126
- version.to_s.must_equal '2.1.3-5'
126
+ expect(version.to_s).to eq('2.1.3-5')
127
127
  end
128
128
  end
129
129
  end
130
130
  end
131
131
 
132
132
  describe '#to_str' do
133
- def target; 'rpm'; end
133
+ let(:target) { 'rpm' }
134
134
 
135
135
  it 'returns a string representation of the version' do
136
136
  recipe.version = '1.3'
137
137
  recipe.vendor = 'foo'
138
138
  recipe.revision = 1
139
139
 
140
- version.to_str.must_equal '1.3-1.foo'
140
+ expect(version.to_str).to eq('1.3-1.foo')
141
141
  end
142
142
  end
143
143
  end
@@ -2,14 +2,14 @@ require 'spec_helper'
2
2
  require 'fpm/cookery/path_helper'
3
3
 
4
4
  describe "PathHelper" do
5
- class PathTest
6
- include FPM::Cookery::PathHelper
5
+ let(:helper) do
6
+ Class.new {
7
+ include FPM::Cookery::PathHelper
7
8
 
8
- def destdir; FPM::Cookery::Path.new('/tmp/dest') end
9
+ def destdir; FPM::Cookery::Path.new('/tmp/dest') end
10
+ }.new
9
11
  end
10
12
 
11
- let(:helper) { PathTest.new }
12
-
13
13
  describe "path helper methods" do
14
14
  [ ['prefix', '/usr'],
15
15
  ['root_prefix', '/'],
@@ -42,19 +42,19 @@ describe "PathHelper" do
42
42
 
43
43
  context "without an argument" do
44
44
  it "returns #{path}" do
45
- helper.send(name).to_s.must_equal path
45
+ expect(helper.send(name).to_s).to eq(path)
46
46
  end
47
47
  end
48
48
 
49
49
  context "with an argument" do
50
50
  it "adds the argument to the path" do
51
- helper.send(name, 'foo/bar').to_s.must_equal c("#{path}/foo/bar")
51
+ expect(helper.send(name, 'foo/bar').to_s).to eq(c("#{path}/foo/bar"))
52
52
  end
53
53
  end
54
54
 
55
55
  context "with a nil argument" do
56
56
  it "does not add anything to the path" do
57
- helper.send(name, nil).to_s.must_equal path
57
+ expect(helper.send(name, nil).to_s).to eq(path)
58
58
  end
59
59
  end
60
60
 
@@ -62,7 +62,7 @@ describe "PathHelper" do
62
62
  before { helper.installing = true}
63
63
 
64
64
  it "adds the destdir as prefix" do
65
- helper.send(name, 'blah').to_s.must_equal c("#{helper.destdir}#{path}/blah")
65
+ expect(helper.send(name, 'blah').to_s).to eq(c("#{helper.destdir}#{path}/blah"))
66
66
  end
67
67
  end
68
68
 
@@ -70,7 +70,7 @@ describe "PathHelper" do
70
70
  before { helper.omnibus_installing = true }
71
71
 
72
72
  it "does not add anything to the path" do
73
- helper.send(name, 'blah').to_s.must_equal c("#{path}/blah")
73
+ expect(helper.send(name, 'blah').to_s).to eq(c("#{path}/blah"))
74
74
  end
75
75
  end
76
76
 
@@ -78,7 +78,7 @@ describe "PathHelper" do
78
78
  before { helper.omnibus_installing = true ; helper.installing = true }
79
79
 
80
80
  it "does not add anything to the path" do
81
- helper.send(name, 'blah').to_s.must_equal c("#{path}/blah")
81
+ expect(helper.send(name, 'blah').to_s).to eq(c("#{path}/blah"))
82
82
  end
83
83
  end
84
84
  end
@@ -90,7 +90,7 @@ describe "PathHelper" do
90
90
  before { helper.installing = true}
91
91
 
92
92
  it "returns true" do
93
- helper.installing?.must_equal true
93
+ expect(helper.installing?).to eq(true)
94
94
  end
95
95
  end
96
96
 
@@ -98,7 +98,7 @@ describe "PathHelper" do
98
98
  before { helper.installing = false }
99
99
 
100
100
  it "returns true" do
101
- helper.installing?.must_equal false
101
+ expect(helper.installing?).to eq(false)
102
102
  end
103
103
  end
104
104
  end
@@ -108,7 +108,7 @@ describe "PathHelper" do
108
108
  before { helper.omnibus_installing = true }
109
109
 
110
110
  it "returns true" do
111
- helper.omnibus_installing?.must_equal true
111
+ expect(helper.omnibus_installing?).to eq(true)
112
112
  end
113
113
  end
114
114
 
@@ -116,7 +116,7 @@ describe "PathHelper" do
116
116
  before { helper.omnibus_installing = false }
117
117
 
118
118
  it "returns false" do
119
- helper.omnibus_installing?.must_equal false
119
+ expect(helper.omnibus_installing?).to eq(false)
120
120
  end
121
121
  end
122
122
  end
@@ -127,13 +127,13 @@ describe "PathHelper" do
127
127
 
128
128
  specify "prefix returns /" do
129
129
  helper.with_trueprefix do
130
- helper.prefix.to_s.must_equal '/usr'
130
+ expect(helper.prefix.to_s).to eq('/usr')
131
131
  end
132
132
  end
133
133
 
134
134
  it "will restore the previous installing value" do
135
135
  helper.with_trueprefix {}
136
- helper.installing.must_equal true
136
+ expect(helper.installing).to eq(true)
137
137
  end
138
138
  end
139
139
 
@@ -142,13 +142,13 @@ describe "PathHelper" do
142
142
 
143
143
  specify "prefix returns /" do
144
144
  helper.with_trueprefix do
145
- helper.prefix.to_s.must_equal '/usr'
145
+ expect(helper.prefix.to_s).to eq('/usr')
146
146
  end
147
147
  end
148
148
 
149
149
  it "will restore the previous installing value" do
150
150
  helper.with_trueprefix {}
151
- helper.installing.must_equal false
151
+ expect(helper.installing).to eq(false)
152
152
  end
153
153
  end
154
154
  end