chefspec 7.3.3 → 7.3.4
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.
- checksums.yaml +4 -4
- data/Gemfile +23 -0
- data/Rakefile +77 -0
- data/chefspec.gemspec +29 -0
- data/lib/chefspec/version.rb +1 -1
- data/spec/spec_helper.rb +13 -0
- data/spec/support/hash.rb +35 -0
- data/spec/unit/cacher_spec.rb +70 -0
- data/spec/unit/coverage/filters_spec.rb +60 -0
- data/spec/unit/deprecations_spec.rb +53 -0
- data/spec/unit/errors_spec.rb +57 -0
- data/spec/unit/expect_exception_spec.rb +32 -0
- data/spec/unit/macros_spec.rb +119 -0
- data/spec/unit/matchers/do_nothing_matcher.rb +5 -0
- data/spec/unit/matchers/include_recipe_matcher_spec.rb +38 -0
- data/spec/unit/matchers/link_to_matcher_spec.rb +55 -0
- data/spec/unit/matchers/notifications_matcher_spec.rb +40 -0
- data/spec/unit/matchers/render_file_matcher_spec.rb +68 -0
- data/spec/unit/matchers/resource_matcher_spec.rb +5 -0
- data/spec/unit/matchers/state_attrs_matcher_spec.rb +68 -0
- data/spec/unit/matchers/subscribes_matcher_spec.rb +65 -0
- data/spec/unit/renderer_spec.rb +69 -0
- data/spec/unit/server_runner_spec.rb +28 -0
- data/spec/unit/solo_runner_spec.rb +171 -0
- data/spec/unit/stubs/command_registry_spec.rb +27 -0
- data/spec/unit/stubs/command_stub_spec.rb +61 -0
- data/spec/unit/stubs/data_bag_item_registry_spec.rb +39 -0
- data/spec/unit/stubs/data_bag_item_stub_spec.rb +36 -0
- data/spec/unit/stubs/data_bag_registry_spec.rb +39 -0
- data/spec/unit/stubs/data_bag_stub_spec.rb +35 -0
- data/spec/unit/stubs/registry_spec.rb +29 -0
- data/spec/unit/stubs/search_registry_spec.rb +39 -0
- data/spec/unit/stubs/search_stub_spec.rb +36 -0
- data/spec/unit/stubs/stub_spec.rb +64 -0
- metadata +34 -2
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ChefSpec::Stubs::DataBagStub do
|
4
|
+
it 'inherts from Stub' do
|
5
|
+
expect(described_class.superclass).to be(ChefSpec::Stubs::Stub)
|
6
|
+
end
|
7
|
+
|
8
|
+
describe '#initialize' do
|
9
|
+
it 'sets the bag and block' do
|
10
|
+
block = Proc.new {}
|
11
|
+
stub = described_class.new('bag', &block)
|
12
|
+
|
13
|
+
expect(stub.bag).to eq('bag')
|
14
|
+
expect(stub.block).to eq(block)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#signature' do
|
19
|
+
context 'when a value is given' do
|
20
|
+
subject { described_class.new('bag').and_return(false) }
|
21
|
+
|
22
|
+
it 'includes the value' do
|
23
|
+
expect(subject.signature).to eq('stub_data_bag("bag").and_return(false)')
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'when a block is given' do
|
28
|
+
subject { described_class.new('bag') { 1 == 2 } }
|
29
|
+
|
30
|
+
it 'includes a comment about the block' do
|
31
|
+
expect(subject.signature).to eq('stub_data_bag("bag") { # Ruby code }')
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ChefSpec::Stubs::Registry do
|
4
|
+
before { described_class.reset! }
|
5
|
+
|
6
|
+
describe '#reset!' do
|
7
|
+
it 'cleans the list of stubs' do
|
8
|
+
described_class.stubs = [1, 2, 3]
|
9
|
+
described_class.reset!
|
10
|
+
|
11
|
+
expect(described_class.stubs).to be_empty
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#register' do
|
16
|
+
it 'adds the stub to the registry' do
|
17
|
+
described_class.register('bacon')
|
18
|
+
expect(described_class.stubs).to include('bacon')
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '#stub_for' do
|
23
|
+
it 'finds a stub by name' do
|
24
|
+
expect {
|
25
|
+
described_class.stub_for
|
26
|
+
}.to raise_error(ArgumentError)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ChefSpec::Stubs::SearchRegistry do
|
4
|
+
before { described_class.reset! }
|
5
|
+
|
6
|
+
it 'inherits from Registry' do
|
7
|
+
expect(described_class.superclass).to be(ChefSpec::Stubs::Registry)
|
8
|
+
end
|
9
|
+
|
10
|
+
describe '#stub_for' do
|
11
|
+
it 'finds a stub by name' do
|
12
|
+
search = double('search', type: 'node', query: '*:*')
|
13
|
+
described_class.register(search)
|
14
|
+
expect(described_class.stub_for('node', '*:*')).to eq(search)
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'finds a stub by Regex' do
|
18
|
+
search = double('search', type: 'node', query: /name:(.+)/)
|
19
|
+
described_class.register(search)
|
20
|
+
expect(described_class.stub_for('node', 'name:example.com')).to eq(search)
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'matches when the type is Symbol' do
|
24
|
+
search = double('search', type: :node, query: '*:*')
|
25
|
+
described_class.register(search)
|
26
|
+
expect(described_class.stub_for('node', '*:*')).to eq(search)
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'matches when the stub is Symbol' do
|
30
|
+
search = double('search', type: 'node', query: '*:*')
|
31
|
+
described_class.register(search)
|
32
|
+
expect(described_class.stub_for(:node, '*:*')).to eq(search)
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'returns nil when no searches are matched' do
|
36
|
+
expect(described_class.stub_for('node', 'name:example.com')).to eq(nil)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ChefSpec::Stubs::SearchStub do
|
4
|
+
it 'inherts from Stub' do
|
5
|
+
expect(described_class.superclass).to be(ChefSpec::Stubs::Stub)
|
6
|
+
end
|
7
|
+
|
8
|
+
describe '#initialize' do
|
9
|
+
it 'sets the type, query, and block' do
|
10
|
+
block = Proc.new {}
|
11
|
+
stub = described_class.new('type', 'query', &block)
|
12
|
+
|
13
|
+
expect(stub.type).to eq('type')
|
14
|
+
expect(stub.query).to eq('query')
|
15
|
+
expect(stub.block).to eq(block)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe '#signature' do
|
20
|
+
context 'when a value is given' do
|
21
|
+
subject { described_class.new('type', 'query').and_return(false) }
|
22
|
+
|
23
|
+
it 'includes the value' do
|
24
|
+
expect(subject.signature).to eq('stub_search("type", "query").and_return(false)')
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context 'when a block is given' do
|
29
|
+
subject { described_class.new('type', 'query') { 1 == 2 } }
|
30
|
+
|
31
|
+
it 'includes a comment about the block' do
|
32
|
+
expect(subject.signature).to eq('stub_search("type", "query") { # Ruby code }')
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ChefSpec::Stubs::Stub do
|
4
|
+
describe '#and_return' do
|
5
|
+
subject { described_class.new.and_return('value') }
|
6
|
+
|
7
|
+
it 'sets the value' do
|
8
|
+
expect(subject.value).to eq('value')
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'returns an instance of the stub' do
|
12
|
+
expect(subject.and_return('value')).to be(subject)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '#and_raise' do
|
17
|
+
subject { described_class.new.and_raise(ArgumentError) }
|
18
|
+
|
19
|
+
it 'sets the block' do
|
20
|
+
expect(subject.instance_variable_get(:@block)).to be_a(Proc)
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'returns an instance of the stub' do
|
24
|
+
expect(subject.and_raise(ArgumentError)).to be(subject)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '#result' do
|
29
|
+
context 'when a value is given' do
|
30
|
+
subject { described_class.new.and_return('value') }
|
31
|
+
|
32
|
+
it 'returns the value' do
|
33
|
+
expect(subject.result).to eq('value')
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context 'when a block is given' do
|
38
|
+
subject { described_class.new }
|
39
|
+
|
40
|
+
it 'calls the block' do
|
41
|
+
subject.instance_variable_set(:@block, Proc.new { 1 == 2 })
|
42
|
+
expect(subject.result).to eq(false)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context 'when an exception block is given' do
|
47
|
+
subject { described_class.new.and_raise(ArgumentError) }
|
48
|
+
|
49
|
+
it 'raises the exception' do
|
50
|
+
expect {
|
51
|
+
subject.result
|
52
|
+
}.to raise_error(ArgumentError)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
context 'when the value is a Hash' do
|
57
|
+
subject { described_class.new.and_return([ { name: 'a' } ]) }
|
58
|
+
|
59
|
+
it 'recursively mashifies the value' do
|
60
|
+
expect(subject.result.first).to be_a(Mash)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chefspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 7.3.
|
4
|
+
version: 7.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Crump
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-12-
|
12
|
+
date: 2018-12-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: chef
|
@@ -63,7 +63,10 @@ executables: []
|
|
63
63
|
extensions: []
|
64
64
|
extra_rdoc_files: []
|
65
65
|
files:
|
66
|
+
- Gemfile
|
66
67
|
- LICENSE
|
68
|
+
- Rakefile
|
69
|
+
- chefspec.gemspec
|
67
70
|
- lib/chefspec.rb
|
68
71
|
- lib/chefspec/api.rb
|
69
72
|
- lib/chefspec/api/core.rb
|
@@ -135,6 +138,35 @@ files:
|
|
135
138
|
- lib/chefspec/util.rb
|
136
139
|
- lib/chefspec/version.rb
|
137
140
|
- lib/chefspec/zero_server.rb
|
141
|
+
- spec/spec_helper.rb
|
142
|
+
- spec/support/hash.rb
|
143
|
+
- spec/unit/cacher_spec.rb
|
144
|
+
- spec/unit/coverage/filters_spec.rb
|
145
|
+
- spec/unit/deprecations_spec.rb
|
146
|
+
- spec/unit/errors_spec.rb
|
147
|
+
- spec/unit/expect_exception_spec.rb
|
148
|
+
- spec/unit/macros_spec.rb
|
149
|
+
- spec/unit/matchers/do_nothing_matcher.rb
|
150
|
+
- spec/unit/matchers/include_recipe_matcher_spec.rb
|
151
|
+
- spec/unit/matchers/link_to_matcher_spec.rb
|
152
|
+
- spec/unit/matchers/notifications_matcher_spec.rb
|
153
|
+
- spec/unit/matchers/render_file_matcher_spec.rb
|
154
|
+
- spec/unit/matchers/resource_matcher_spec.rb
|
155
|
+
- spec/unit/matchers/state_attrs_matcher_spec.rb
|
156
|
+
- spec/unit/matchers/subscribes_matcher_spec.rb
|
157
|
+
- spec/unit/renderer_spec.rb
|
158
|
+
- spec/unit/server_runner_spec.rb
|
159
|
+
- spec/unit/solo_runner_spec.rb
|
160
|
+
- spec/unit/stubs/command_registry_spec.rb
|
161
|
+
- spec/unit/stubs/command_stub_spec.rb
|
162
|
+
- spec/unit/stubs/data_bag_item_registry_spec.rb
|
163
|
+
- spec/unit/stubs/data_bag_item_stub_spec.rb
|
164
|
+
- spec/unit/stubs/data_bag_registry_spec.rb
|
165
|
+
- spec/unit/stubs/data_bag_stub_spec.rb
|
166
|
+
- spec/unit/stubs/registry_spec.rb
|
167
|
+
- spec/unit/stubs/search_registry_spec.rb
|
168
|
+
- spec/unit/stubs/search_stub_spec.rb
|
169
|
+
- spec/unit/stubs/stub_spec.rb
|
138
170
|
- templates/coverage/human.erb
|
139
171
|
- templates/coverage/json.erb
|
140
172
|
- templates/coverage/table.erb
|