omnijack 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/.travis.yml +6 -0
- data/CHANGELOG.md +11 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +15 -0
- data/NOTICE +5 -0
- data/README.md +119 -0
- data/Rakefile +23 -0
- data/features/list.feature +19 -0
- data/features/metadata.feature +43 -0
- data/features/platforms.feature +23 -0
- data/features/step_definitions/list.rb +12 -0
- data/features/step_definitions/metadata.rb +20 -0
- data/features/step_definitions/platforms.rb +8 -0
- data/features/step_definitions/project.rb +20 -0
- data/features/support/env.rb +4 -0
- data/lib/omnijack/config.rb +67 -0
- data/lib/omnijack/list.rb +94 -0
- data/lib/omnijack/metadata.rb +244 -0
- data/lib/omnijack/platforms.rb +96 -0
- data/lib/omnijack/project/metaprojects.rb +38 -0
- data/lib/omnijack/project.rb +63 -0
- data/lib/omnijack/version.rb +24 -0
- data/lib/omnijack.rb +54 -0
- data/omnijack.gemspec +37 -0
- data/spec/omnijack/config_spec.rb +55 -0
- data/spec/omnijack/list_spec.rb +133 -0
- data/spec/omnijack/metadata_spec.rb +577 -0
- data/spec/omnijack/platforms_spec.rb +132 -0
- data/spec/omnijack/project/angry_chef_spec.rb +55 -0
- data/spec/omnijack/project/chef_container_spec.rb +55 -0
- data/spec/omnijack/project/chef_dk_spec.rb +55 -0
- data/spec/omnijack/project/chef_server_spec.rb +55 -0
- data/spec/omnijack/project/chef_spec.rb +55 -0
- data/spec/omnijack/project_spec.rb +52 -0
- data/spec/omnijack_spec.rb +109 -0
- data/spec/spec_helper.rb +38 -0
- data/spec/support/real_test_data.json +131 -0
- data/vendor/chef/LICENSE +201 -0
- data/vendor/chef/NOTICE +21 -0
- data/vendor/chef/lib/chef/exceptions.rb +353 -0
- data/vendor/chef/lib/chef/mixin/params_validate.rb +242 -0
- metadata +276 -0
@@ -0,0 +1,132 @@
|
|
1
|
+
# Encoding: UTF-8
|
2
|
+
#
|
3
|
+
# Author:: Jonathan Hartman (<j@p4nt5.com>)
|
4
|
+
#
|
5
|
+
# Copyright (C) 2014, Jonathan Hartman
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
|
19
|
+
require_relative '../spec_helper'
|
20
|
+
require_relative '../../lib/omnijack/platforms'
|
21
|
+
|
22
|
+
describe Omnijack::Platforms do
|
23
|
+
let(:name) { :chef_dk }
|
24
|
+
let(:obj) { described_class.new(name) }
|
25
|
+
|
26
|
+
describe '#method_missing' do
|
27
|
+
let(:to_h) { { thing1: 'yup', thing2: 'nope', thing3: 'maybe' } }
|
28
|
+
|
29
|
+
before(:each) do
|
30
|
+
allow_any_instance_of(described_class).to receive(:to_h).and_return(to_h)
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'sets up methods for the platform hash keys' do
|
34
|
+
expect(obj.thing1).to eq('yup')
|
35
|
+
expect(obj.thing2).to eq('nope')
|
36
|
+
expect(obj.thing3).to eq('maybe')
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'raises an exception otherwise' do
|
40
|
+
expect { obj.thing4 }.to raise_error(NoMethodError)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe '#[]' do
|
45
|
+
let(:to_h) { { thing1: 'yup', thing2: 'nope', thing3: 'maybe' } }
|
46
|
+
|
47
|
+
before(:each) do
|
48
|
+
allow_any_instance_of(described_class).to receive(:to_h).and_return(to_h)
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'returns the correct data' do
|
52
|
+
expect(obj[:thing1]).to eq('yup')
|
53
|
+
expect(obj[:thing2]).to eq('nope')
|
54
|
+
expect(obj[:thing3]).to eq('maybe')
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe '#to_h' do
|
59
|
+
context 'fake data' do
|
60
|
+
let(:raw_data) { '{"thing1": "yup", "thing2": "nope"}' }
|
61
|
+
|
62
|
+
before(:each) do
|
63
|
+
allow_any_instance_of(described_class).to receive(:raw_data)
|
64
|
+
.and_return(raw_data)
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'returns the correct result hash' do
|
68
|
+
expect(obj.to_h).to eq(thing1: 'yup', thing2: 'nope')
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
context 'real data' do
|
73
|
+
let(:obj) { described_class.new(:chef) }
|
74
|
+
|
75
|
+
it 'returns the expected data' do
|
76
|
+
expect(obj.to_h[:el]).to eq('Enterprise Linux')
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe '#to_s' do
|
82
|
+
let(:raw_data) { 'SOME STUFF' }
|
83
|
+
|
84
|
+
before(:each) do
|
85
|
+
allow_any_instance_of(described_class).to receive(:raw_data)
|
86
|
+
.and_return(raw_data)
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'returns the raw HTTP GET string' do
|
90
|
+
expect(obj.to_s).to eq(raw_data)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
describe '#raw_data' do
|
95
|
+
let(:read) { '{"thing1": "yup", "thing2": "nope"}' }
|
96
|
+
let(:open) { double(read: read) }
|
97
|
+
|
98
|
+
before(:each) do
|
99
|
+
allow_any_instance_of(URI::HTTP).to receive(:open).and_return(open)
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'returns a GET of the API URL' do
|
103
|
+
res = obj
|
104
|
+
expect(res.send(:raw_data)).to eq(read)
|
105
|
+
expect(res.instance_variable_get(:@raw_data)).to eq(read)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
describe '#api_url' do
|
110
|
+
let(:base_url) { 'http://example.com/chef' }
|
111
|
+
let(:endpoint) { '/example_platform_names' }
|
112
|
+
|
113
|
+
before(:each) do
|
114
|
+
[:base_url, :endpoint].each do |i|
|
115
|
+
allow_any_instance_of(described_class).to receive(i).and_return(send(i))
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
it 'constructs a URL based on base + endpoint' do
|
120
|
+
expected = URI.parse('http://example.com/chef/example_platform_names')
|
121
|
+
expect(obj.send(:api_url)).to eq(expected)
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
describe '#endpoint' do
|
126
|
+
let(:name) { :chef_container }
|
127
|
+
|
128
|
+
it 'returns the appropriate metadata endpoint' do
|
129
|
+
expect(obj.send(:endpoint)).to eq('/chef_container_platform_names')
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# Encoding: UTF-8
|
2
|
+
#
|
3
|
+
# Author:: Jonathan Hartman (<j@p4nt5.com>)
|
4
|
+
#
|
5
|
+
# Copyright (C) 2014, Jonathan Hartman
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
|
19
|
+
require_relative '../../spec_helper'
|
20
|
+
require_relative '../../../lib/omnijack/project/metaprojects'
|
21
|
+
|
22
|
+
describe Omnijack::Project::AngryChef do
|
23
|
+
let(:args) { nil }
|
24
|
+
let(:obj) { described_class.new(args) }
|
25
|
+
|
26
|
+
describe '#initialize' do
|
27
|
+
context 'no additional args' do
|
28
|
+
it 'initializes an angry_chef project' do
|
29
|
+
res = obj
|
30
|
+
expect(res.name).to eq(:angry_chef)
|
31
|
+
expect(res.instance_variable_get(:@name)).to eq(:angry_chef)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'some additional args' do
|
36
|
+
let(:args) { { version: '6.6.6', prerelease: true } }
|
37
|
+
|
38
|
+
it 'holds onto those args' do
|
39
|
+
res = obj
|
40
|
+
expect(res.args).to eq(args)
|
41
|
+
expect(res.instance_variable_get(:@args)).to eq(args)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe '#name' do
|
47
|
+
it 'returns angry_chef' do
|
48
|
+
expect(obj.name).to eq(:angry_chef)
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'refuses attempts to override' do
|
52
|
+
expect { obj.name('bad') }.to raise_error
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# Encoding: UTF-8
|
2
|
+
#
|
3
|
+
# Author:: Jonathan Hartman (<j@p4nt5.com>)
|
4
|
+
#
|
5
|
+
# Copyright (C) 2014, Jonathan Hartman
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
|
19
|
+
require_relative '../../spec_helper'
|
20
|
+
require_relative '../../../lib/omnijack/project/metaprojects'
|
21
|
+
|
22
|
+
describe Omnijack::Project::ChefContainer do
|
23
|
+
let(:args) { nil }
|
24
|
+
let(:obj) { described_class.new(args) }
|
25
|
+
|
26
|
+
describe '#initialize' do
|
27
|
+
context 'no additional args' do
|
28
|
+
it 'initializes a chef_container project' do
|
29
|
+
res = obj
|
30
|
+
expect(res.name).to eq(:chef_container)
|
31
|
+
expect(res.instance_variable_get(:@name)).to eq(:chef_container)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'some additional args' do
|
36
|
+
let(:args) { { version: '6.6.6', prerelease: true } }
|
37
|
+
|
38
|
+
it 'holds onto those args' do
|
39
|
+
res = obj
|
40
|
+
expect(res.args).to eq(args)
|
41
|
+
expect(res.instance_variable_get(:@args)).to eq(args)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe '#name' do
|
47
|
+
it 'returns chef_container' do
|
48
|
+
expect(obj.name).to eq(:chef_container)
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'refuses attempts to override' do
|
52
|
+
expect { obj.name('bad') }.to raise_error
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# Encoding: UTF-8
|
2
|
+
#
|
3
|
+
# Author:: Jonathan Hartman (<j@p4nt5.com>)
|
4
|
+
#
|
5
|
+
# Copyright (C) 2014, Jonathan Hartman
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
|
19
|
+
require_relative '../../spec_helper'
|
20
|
+
require_relative '../../../lib/omnijack/project/metaprojects'
|
21
|
+
|
22
|
+
describe Omnijack::Project::ChefDk do
|
23
|
+
let(:args) { nil }
|
24
|
+
let(:obj) { described_class.new(args) }
|
25
|
+
|
26
|
+
describe '#initialize' do
|
27
|
+
context 'no additional args' do
|
28
|
+
it 'initializes a chef_dk project' do
|
29
|
+
res = obj
|
30
|
+
expect(res.name).to eq(:chef_dk)
|
31
|
+
expect(res.instance_variable_get(:@name)).to eq(:chef_dk)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'some additional args' do
|
36
|
+
let(:args) { { version: '6.6.6', prerelease: true } }
|
37
|
+
|
38
|
+
it 'holds onto those args' do
|
39
|
+
res = obj
|
40
|
+
expect(res.args).to eq(args)
|
41
|
+
expect(res.instance_variable_get(:@args)).to eq(args)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe '#name' do
|
47
|
+
it 'returns chef_dk' do
|
48
|
+
expect(obj.name).to eq(:chef_dk)
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'refuses attempts to override' do
|
52
|
+
expect { obj.name('bad') }.to raise_error
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# Encoding: UTF-8
|
2
|
+
#
|
3
|
+
# Author:: Jonathan Hartman (<j@p4nt5.com>)
|
4
|
+
#
|
5
|
+
# Copyright (C) 2014, Jonathan Hartman
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
|
19
|
+
require_relative '../../spec_helper'
|
20
|
+
require_relative '../../../lib/omnijack/project/metaprojects'
|
21
|
+
|
22
|
+
describe Omnijack::Project::ChefServer do
|
23
|
+
let(:args) { nil }
|
24
|
+
let(:obj) { described_class.new(args) }
|
25
|
+
|
26
|
+
describe '#initialize' do
|
27
|
+
context 'no additional args' do
|
28
|
+
it 'initializes a chef_server project' do
|
29
|
+
res = obj
|
30
|
+
expect(res.name).to eq(:chef_server)
|
31
|
+
expect(res.instance_variable_get(:@name)).to eq(:chef_server)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'some additional args' do
|
36
|
+
let(:args) { { version: '6.6.6', prerelease: true } }
|
37
|
+
|
38
|
+
it 'holds onto those args' do
|
39
|
+
res = obj
|
40
|
+
expect(res.args).to eq(args)
|
41
|
+
expect(res.instance_variable_get(:@args)).to eq(args)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe '#name' do
|
47
|
+
it 'returns chef_server' do
|
48
|
+
expect(obj.name).to eq(:chef_server)
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'refuses attempts to override' do
|
52
|
+
expect { obj.name('bad') }.to raise_error
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# Encoding: UTF-8
|
2
|
+
#
|
3
|
+
# Author:: Jonathan Hartman (<j@p4nt5.com>)
|
4
|
+
#
|
5
|
+
# Copyright (C) 2014, Jonathan Hartman
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
|
19
|
+
require_relative '../../spec_helper'
|
20
|
+
require_relative '../../../lib/omnijack/project/metaprojects'
|
21
|
+
|
22
|
+
describe Omnijack::Project::Chef do
|
23
|
+
let(:args) { nil }
|
24
|
+
let(:obj) { described_class.new(args) }
|
25
|
+
|
26
|
+
describe '#initialize' do
|
27
|
+
context 'no additional args' do
|
28
|
+
it 'initializes a chef project' do
|
29
|
+
res = obj
|
30
|
+
expect(res.name).to eq(:chef)
|
31
|
+
expect(res.instance_variable_get(:@name)).to eq(:chef)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'some additional args' do
|
36
|
+
let(:args) { { version: '6.6.6', prerelease: true } }
|
37
|
+
|
38
|
+
it 'holds onto those args' do
|
39
|
+
res = obj
|
40
|
+
expect(res.args).to eq(args)
|
41
|
+
expect(res.instance_variable_get(:@args)).to eq(args)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe '#name' do
|
47
|
+
it 'returns chef' do
|
48
|
+
expect(obj.name).to eq(:chef)
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'refuses attempts to override' do
|
52
|
+
expect { obj.name('bad') }.to raise_error
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# Encoding: UTF-8
|
2
|
+
#
|
3
|
+
# Author:: Jonathan Hartman (<j@p4nt5.com>)
|
4
|
+
#
|
5
|
+
# Copyright (C) 2014, Jonathan Hartman
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
|
19
|
+
require_relative '../spec_helper'
|
20
|
+
require_relative '../../lib/omnijack/project'
|
21
|
+
|
22
|
+
describe Omnijack::Project do
|
23
|
+
let(:args) { nil }
|
24
|
+
let(:obj) { described_class.new(:chef_dk, args) }
|
25
|
+
|
26
|
+
describe '#list' do
|
27
|
+
it 'returns a List object' do
|
28
|
+
res = obj
|
29
|
+
[res.list, res.instance_variable_get(:@list)].each do |i|
|
30
|
+
expect(i).to be_an_instance_of(Omnijack::List)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '#metadata' do
|
36
|
+
it 'returns a Metadata object' do
|
37
|
+
res = obj
|
38
|
+
[res.metadata, res.instance_variable_get(:@metadata)].each do |i|
|
39
|
+
expect(i).to be_an_instance_of(Omnijack::Metadata)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe '#platforms' do
|
45
|
+
it 'returns a Platforms object' do
|
46
|
+
res = obj
|
47
|
+
[res.platforms, res.instance_variable_get(:@platforms)].each do |i|
|
48
|
+
expect(i).to be_an_instance_of(Omnijack::Platforms)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,109 @@
|
|
1
|
+
# Encoding: UTF-8
|
2
|
+
#
|
3
|
+
# Author:: Jonathan Hartman (<j@p4nt5.com>)
|
4
|
+
#
|
5
|
+
# Copyright (C) 2014, Jonathan Hartman
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
|
19
|
+
require_relative 'spec_helper'
|
20
|
+
require_relative '../lib/omnijack'
|
21
|
+
|
22
|
+
describe Omnijack do
|
23
|
+
let(:name) { :chef_dk }
|
24
|
+
let(:args) { nil }
|
25
|
+
let(:obj) { described_class.new(name, args) }
|
26
|
+
|
27
|
+
describe '#initialize' do
|
28
|
+
shared_examples_for 'any context' do
|
29
|
+
it 'sets the project name' do
|
30
|
+
expect(obj.name).to eq(:chef_dk)
|
31
|
+
expect(obj.instance_variable_get(:@name)).to eq(:chef_dk)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'no args provided' do
|
36
|
+
let(:obj) { described_class.new(name) }
|
37
|
+
|
38
|
+
it_behaves_like 'any context'
|
39
|
+
|
40
|
+
it 'holds an empty hash for the args' do
|
41
|
+
expect(obj.args).to eq({})
|
42
|
+
expect(obj.instance_variable_get(:@args)).to eq({})
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context 'some additional args' do
|
47
|
+
let(:args) { { pants: 'off', shorts: 'on' } }
|
48
|
+
|
49
|
+
it_behaves_like 'any context'
|
50
|
+
|
51
|
+
it 'holds onto the args' do
|
52
|
+
expect(obj.args).to eq(args)
|
53
|
+
expect(obj.instance_variable_get(:@args)).to eq(args)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
context 'a base_url arg provided' do
|
58
|
+
let(:args) { { base_url: 'https://example.com' } }
|
59
|
+
|
60
|
+
it 'sets the given arg' do
|
61
|
+
expect(obj.send(:base_url)).to eq(args[:base_url])
|
62
|
+
expect(obj.instance_variable_get(:@base_url)).to eq(args[:base_url])
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe '#base_url' do
|
68
|
+
context 'no argument provided' do
|
69
|
+
it 'uses the default' do
|
70
|
+
res = obj
|
71
|
+
expected = 'https://www.getchef.com/chef'
|
72
|
+
expect(res.base_url).to eq(expected)
|
73
|
+
expect(res.instance_variable_get(:@base_url)).to eq(expected)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
context 'a valid argument provided' do
|
78
|
+
let(:obj) do
|
79
|
+
o = super()
|
80
|
+
o.base_url('http://example.com') && o
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'uses the provided arg' do
|
84
|
+
expect(obj.base_url).to eq('http://example.com')
|
85
|
+
expect(obj.instance_variable_get(:@base_url))
|
86
|
+
.to eq('http://example.com')
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
context 'an invalid argument provided' do
|
91
|
+
let(:obj) do
|
92
|
+
o = super()
|
93
|
+
o.base_url(:hello) && o
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'raises an exception' do
|
97
|
+
expect { obj }.to raise_error(Chef::Exceptions::ValidationFailed)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
describe '#name' do
|
103
|
+
let(:name) { 'chef_container' }
|
104
|
+
|
105
|
+
it 'returns the project name, symbolized' do
|
106
|
+
expect(obj.name).to eq(:chef_container)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# Encoding: UTF-8
|
2
|
+
#
|
3
|
+
# Author:: Jonathan Hartman (<j@p4nt5.com>)
|
4
|
+
#
|
5
|
+
# Copyright (C) 2014, Jonathan Hartman
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
#
|
19
|
+
|
20
|
+
require 'net/http'
|
21
|
+
require 'rspec'
|
22
|
+
require 'simplecov'
|
23
|
+
require 'simplecov-console'
|
24
|
+
require 'coveralls'
|
25
|
+
|
26
|
+
RSpec.configure do |c|
|
27
|
+
c.color = true
|
28
|
+
end
|
29
|
+
|
30
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
31
|
+
Coveralls::SimpleCov::Formatter,
|
32
|
+
SimpleCov::Formatter::HTMLFormatter,
|
33
|
+
SimpleCov::Formatter::Console
|
34
|
+
]
|
35
|
+
SimpleCov.minimum_coverage 90
|
36
|
+
SimpleCov.start do
|
37
|
+
add_filter 'vendor/*'
|
38
|
+
end
|