chefspec 9.2.1 → 9.3.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.
- checksums.yaml +4 -4
- data/Gemfile +16 -9
- data/Rakefile +60 -52
- data/chefspec.gemspec +20 -20
- data/lib/chefspec.rb +29 -29
- data/lib/chefspec/api.rb +14 -14
- data/lib/chefspec/api/core.rb +3 -3
- data/lib/chefspec/api/described.rb +3 -5
- data/lib/chefspec/api/stubs.rb +2 -2
- data/lib/chefspec/api/stubs_for.rb +12 -12
- data/lib/chefspec/berkshelf.rb +4 -4
- data/lib/chefspec/cacher.rb +2 -2
- data/lib/chefspec/coverage.rb +35 -40
- data/lib/chefspec/coverage/filters.rb +18 -15
- data/lib/chefspec/deprecations.rb +3 -3
- data/lib/chefspec/errors.rb +7 -7
- data/lib/chefspec/expect_exception.rb +2 -1
- data/lib/chefspec/extensions.rb +14 -14
- data/lib/chefspec/extensions/chef/client.rb +3 -3
- data/lib/chefspec/extensions/chef/conditional.rb +2 -1
- data/lib/chefspec/extensions/chef/cookbook/gem_installer.rb +5 -4
- data/lib/chefspec/extensions/chef/cookbook_loader.rb +1 -0
- data/lib/chefspec/extensions/chef/cookbook_uploader.rb +1 -1
- data/lib/chefspec/extensions/chef/data_query.rb +3 -3
- data/lib/chefspec/extensions/chef/lwrp_base.rb +1 -0
- data/lib/chefspec/extensions/chef/provider.rb +8 -5
- data/lib/chefspec/extensions/chef/resource.rb +14 -9
- data/lib/chefspec/extensions/chef/resource/freebsd_package.rb +2 -1
- data/lib/chefspec/extensions/chef/run_context/cookbook_compiler.rb +12 -1
- data/lib/chefspec/extensions/chef/securable.rb +1 -1
- data/lib/chefspec/extensions/ohai/system.rb +1 -1
- data/lib/chefspec/file_cache_path_proxy.rb +3 -3
- data/lib/chefspec/formatter.rb +3 -3
- data/lib/chefspec/librarian.rb +7 -6
- data/lib/chefspec/matchers.rb +9 -9
- data/lib/chefspec/matchers/do_nothing_matcher.rb +15 -15
- data/lib/chefspec/matchers/include_any_recipe_matcher.rb +4 -4
- data/lib/chefspec/matchers/include_recipe_matcher.rb +1 -1
- data/lib/chefspec/matchers/link_to_matcher.rb +2 -2
- data/lib/chefspec/matchers/notifications_matcher.rb +5 -4
- data/lib/chefspec/matchers/render_file_matcher.rb +3 -3
- data/lib/chefspec/matchers/resource_matcher.rb +18 -16
- data/lib/chefspec/mixins/normalize.rb +1 -1
- data/lib/chefspec/policyfile.rb +6 -6
- data/lib/chefspec/renderer.rb +4 -4
- data/lib/chefspec/rspec.rb +1 -1
- data/lib/chefspec/server.rb +1 -1
- data/lib/chefspec/server_methods.rb +8 -8
- data/lib/chefspec/server_runner.rb +10 -10
- data/lib/chefspec/solo_runner.rb +26 -24
- data/lib/chefspec/stubs/command_registry.rb +1 -1
- data/lib/chefspec/stubs/command_stub.rb +1 -1
- data/lib/chefspec/stubs/data_bag_item_registry.rb +1 -1
- data/lib/chefspec/stubs/data_bag_item_stub.rb +1 -1
- data/lib/chefspec/stubs/data_bag_registry.rb +1 -1
- data/lib/chefspec/stubs/data_bag_stub.rb +1 -1
- data/lib/chefspec/stubs/registry.rb +1 -1
- data/lib/chefspec/stubs/search_registry.rb +2 -2
- data/lib/chefspec/stubs/search_stub.rb +2 -2
- data/lib/chefspec/util.rb +7 -7
- data/lib/chefspec/version.rb +1 -1
- data/lib/chefspec/zero_server.rb +3 -3
- data/spec/spec_helper.rb +3 -4
- data/spec/support/hash.rb +3 -3
- data/spec/unit/cacher_spec.rb +17 -17
- data/spec/unit/coverage/filters_spec.rb +16 -16
- data/spec/unit/deprecations_spec.rb +8 -9
- data/spec/unit/errors_spec.rb +15 -15
- data/spec/unit/expect_exception_spec.rb +9 -9
- data/spec/unit/macros_spec.rb +50 -50
- data/spec/unit/matchers/do_nothing_matcher.rb +1 -1
- data/spec/unit/matchers/include_any_recipe_matcher_spec.rb +23 -23
- data/spec/unit/matchers/include_recipe_matcher_spec.rb +15 -15
- data/spec/unit/matchers/link_to_matcher_spec.rb +18 -18
- data/spec/unit/matchers/notifications_matcher_spec.rb +15 -16
- data/spec/unit/matchers/render_file_matcher_spec.rb +26 -26
- data/spec/unit/matchers/resource_matcher_spec.rb +1 -1
- data/spec/unit/matchers/state_attrs_matcher_spec.rb +24 -24
- data/spec/unit/matchers/subscribes_matcher_spec.rb +27 -29
- data/spec/unit/renderer_spec.rb +36 -36
- data/spec/unit/server_runner_spec.rb +6 -6
- data/spec/unit/solo_runner_spec.rb +69 -69
- data/spec/unit/stubs/command_registry_spec.rb +11 -11
- data/spec/unit/stubs/command_stub_spec.rb +26 -26
- data/spec/unit/stubs/data_bag_item_registry_spec.rb +17 -17
- data/spec/unit/stubs/data_bag_item_stub_spec.rb +14 -14
- data/spec/unit/stubs/data_bag_registry_spec.rb +16 -16
- data/spec/unit/stubs/data_bag_stub_spec.rb +13 -13
- data/spec/unit/stubs/registry_spec.rb +9 -9
- data/spec/unit/stubs/search_registry_spec.rb +17 -17
- data/spec/unit/stubs/search_stub_spec.rb +14 -14
- data/spec/unit/stubs/stub_spec.rb +22 -22
- metadata +6 -6
@@ -1,65 +1,63 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe ChefSpec::Matchers::SubscribesMatcher do
|
4
|
-
subject { described_class.new(
|
5
|
-
let(:runner) { double(
|
6
|
-
let(:run_context) { double(
|
7
|
-
let(:node) { double(
|
4
|
+
subject { described_class.new("execute[install]") }
|
5
|
+
let(:runner) { double("runner", find_resource: nil) }
|
6
|
+
let(:run_context) { double("run_context", node: node) }
|
7
|
+
let(:node) { double("node", runner: runner) }
|
8
8
|
let(:package) do
|
9
|
-
double(
|
10
|
-
name:
|
11
|
-
to_s:
|
12
|
-
run_context: run_context
|
13
|
-
)
|
9
|
+
double("package",
|
10
|
+
name: "package",
|
11
|
+
to_s: "package[foo]",
|
12
|
+
run_context: run_context)
|
14
13
|
end
|
15
14
|
|
16
|
-
context
|
17
|
-
describe
|
18
|
-
it
|
15
|
+
context "when no resource is found" do
|
16
|
+
describe "#failure_message" do
|
17
|
+
it "has the right value" do
|
19
18
|
subject.matches?(package)
|
20
19
|
expect(subject.failure_message)
|
21
|
-
.to include
|
20
|
+
.to include %{expected _something_ to notify "package[foo]", but the _something_ you gave me was nil! If you are running a test like:}
|
22
21
|
end
|
23
22
|
end
|
24
23
|
end
|
25
24
|
|
26
|
-
context
|
25
|
+
context "when the resource exists" do
|
27
26
|
let(:execute) do
|
28
|
-
double(
|
29
|
-
name:
|
30
|
-
to_s:
|
27
|
+
double("execute",
|
28
|
+
name: "execute",
|
29
|
+
to_s: "execute[install]",
|
31
30
|
immediate_notifications: [],
|
32
31
|
delayed_notifications: [],
|
33
|
-
before_notifications: []
|
34
|
-
)
|
32
|
+
before_notifications: [])
|
35
33
|
end
|
36
34
|
|
37
35
|
before do
|
38
36
|
allow(runner).to receive(:find_resource).and_return(execute)
|
39
37
|
end
|
40
38
|
|
41
|
-
describe
|
42
|
-
it
|
39
|
+
describe "#failure_message" do
|
40
|
+
it "has the right value" do
|
43
41
|
subject.matches?(package)
|
44
42
|
expect(subject.failure_message)
|
45
|
-
.to include
|
43
|
+
.to include %{expected "execute[install]" to notify "package[foo]", but did not.}
|
46
44
|
end
|
47
45
|
end
|
48
46
|
|
49
|
-
describe
|
50
|
-
it
|
47
|
+
describe "#failure_message_when_negated" do
|
48
|
+
it "has the right value" do
|
51
49
|
subject.matches?(package)
|
52
50
|
expect(subject.failure_message_when_negated)
|
53
|
-
.to eq
|
51
|
+
.to eq %{expected "execute[install]" to not notify "package[foo]", but it did.}
|
54
52
|
end
|
55
53
|
end
|
56
54
|
end
|
57
55
|
|
58
|
-
describe
|
59
|
-
it
|
56
|
+
describe "#description" do
|
57
|
+
it "has the right value" do
|
60
58
|
subject.matches?(package)
|
61
59
|
expect(subject.description)
|
62
|
-
.to eq
|
60
|
+
.to eq %{notify "package[foo]"}
|
63
61
|
end
|
64
62
|
end
|
65
63
|
end
|
data/spec/unit/renderer_spec.rb
CHANGED
@@ -1,69 +1,69 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe ChefSpec::Renderer do
|
4
|
-
describe
|
5
|
-
it
|
6
|
-
instance = described_class.new(
|
7
|
-
expect(instance.chef_run).to eq(
|
8
|
-
expect(instance.resource).to eq(
|
4
|
+
describe ".initialize" do
|
5
|
+
it "accepts two arguments and assigns their instance variables" do
|
6
|
+
instance = described_class.new("runner", "resource")
|
7
|
+
expect(instance.chef_run).to eq("runner")
|
8
|
+
expect(instance.resource).to eq("resource")
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
-
let(:chef_run) { double(
|
13
|
-
let(:resource) { double(
|
12
|
+
let(:chef_run) { double("chef_run", { node: "node" }) }
|
13
|
+
let(:resource) { double("resource", { cookbook: "cookbook", source: "source", variables: {} }) }
|
14
14
|
subject { described_class.new(chef_run, resource) }
|
15
15
|
|
16
|
-
describe
|
16
|
+
describe "#content" do
|
17
17
|
before do
|
18
|
-
allow(subject).to receive(:content_from_cookbook_file).and_return(
|
19
|
-
allow(subject).to receive(:content_from_file).and_return(
|
20
|
-
allow(subject).to receive(:content_from_template).and_return(
|
18
|
+
allow(subject).to receive(:content_from_cookbook_file).and_return("cookbook_file content")
|
19
|
+
allow(subject).to receive(:content_from_file).and_return("file content")
|
20
|
+
allow(subject).to receive(:content_from_template).and_return("template content")
|
21
21
|
end
|
22
22
|
|
23
|
-
context
|
24
|
-
it
|
25
|
-
allow(resource).to receive(:resource_name).and_return(
|
26
|
-
expect(subject.content).to eq(
|
23
|
+
context "when the resource is a cookbook_file" do
|
24
|
+
it "renders the cookbook_file content" do
|
25
|
+
allow(resource).to receive(:resource_name).and_return("cookbook_file")
|
26
|
+
expect(subject.content).to eq("cookbook_file content")
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
context
|
31
|
-
it
|
32
|
-
allow(resource).to receive(:resource_name).and_return(
|
33
|
-
expect(subject.content).to eq(
|
30
|
+
context "when the resource is a file" do
|
31
|
+
it "renders the file content" do
|
32
|
+
allow(resource).to receive(:resource_name).and_return("file")
|
33
|
+
expect(subject.content).to eq("file content")
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
-
context
|
38
|
-
it
|
39
|
-
allow(resource).to receive(:resource_name).and_return(
|
40
|
-
expect(subject.content).to eq(
|
37
|
+
context "when the resource is a template" do
|
38
|
+
it "renders the template content" do
|
39
|
+
allow(resource).to receive(:resource_name).and_return("template")
|
40
|
+
expect(subject.content).to eq("template content")
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
-
context
|
45
|
-
it
|
46
|
-
allow(resource).to receive(:resource_name).and_return(
|
44
|
+
context "when the resource is not a file type" do
|
45
|
+
it "returns nil" do
|
46
|
+
allow(resource).to receive(:resource_name).and_return("service")
|
47
47
|
expect(subject.content).to be_nil
|
48
48
|
end
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
-
describe
|
53
|
-
it
|
52
|
+
describe "content_from_template" do
|
53
|
+
it "renders the template by extending modules for rendering paritals within the template" do
|
54
54
|
cookbook_collection = {}
|
55
|
-
cookbook_collection[
|
56
|
-
allow(subject).to receive(:cookbook_collection).with(
|
55
|
+
cookbook_collection["cookbook"] = double("", { preferred_filename_on_disk_location: "/template/location" } )
|
56
|
+
allow(subject).to receive(:cookbook_collection).with("node").and_return(cookbook_collection)
|
57
57
|
allow(subject).to receive(:template_finder)
|
58
|
-
|
58
|
+
|
59
59
|
allow(resource).to receive(:helper_modules).and_return([Module.new])
|
60
|
-
allow(resource).to receive(:resource_name).and_return(
|
60
|
+
allow(resource).to receive(:resource_name).and_return("template")
|
61
61
|
|
62
|
-
chef_template_context = double(
|
62
|
+
chef_template_context = double("context", { render_template: "rendered template content", update: nil })
|
63
63
|
allow(Chef::Mixin::Template::TemplateContext).to receive(:new).and_return(chef_template_context)
|
64
|
-
|
64
|
+
|
65
65
|
expect(chef_template_context).to receive(:_extend_modules).with(resource.helper_modules)
|
66
|
-
expect(subject.content).to eq(
|
66
|
+
expect(subject.content).to eq("rendered template content")
|
67
67
|
end
|
68
68
|
end
|
69
69
|
end
|
@@ -1,8 +1,8 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe ChefSpec::ServerRunner do
|
4
|
-
context
|
5
|
-
it
|
4
|
+
context "when the RSpec config is set" do
|
5
|
+
it "does not create a tmpdir" do
|
6
6
|
allow(RSpec.configuration).to receive(:file_cache_path)
|
7
7
|
.and_return("/foo/bar")
|
8
8
|
expect(ChefSpec::FileCachePathProxy).to_not receive(:instance)
|
@@ -10,15 +10,15 @@ describe ChefSpec::ServerRunner do
|
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
-
context
|
14
|
-
it
|
13
|
+
context "when the RSpec config is not set" do
|
14
|
+
it "creates and returns a tmpdir" do
|
15
15
|
expect(ChefSpec::FileCachePathProxy).to receive(:instance)
|
16
16
|
.and_call_original
|
17
17
|
described_class.new
|
18
18
|
expect(Chef::Config[:file_cache_path]).to match(/chefspec/)
|
19
19
|
end
|
20
20
|
|
21
|
-
it
|
21
|
+
it "uses the same path" do
|
22
22
|
val = ChefSpec::FileCachePathProxy.instance.file_cache_path
|
23
23
|
expect(described_class.new.options[:file_cache_path]).to eq(val)
|
24
24
|
expect(described_class.new.options[:file_cache_path]).to eq(val)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe ChefSpec::SoloRunner do
|
4
4
|
before do
|
@@ -7,7 +7,7 @@ describe ChefSpec::SoloRunner do
|
|
7
7
|
.and_return(true)
|
8
8
|
end
|
9
9
|
|
10
|
-
describe
|
10
|
+
describe "#initialize" do
|
11
11
|
let(:windows_caller_stack) do
|
12
12
|
[
|
13
13
|
"C:/cookbooks/Temp/spec/test_spec.rb:11:in `block (2 levels) in <top (required)>'",
|
@@ -29,22 +29,22 @@ describe ChefSpec::SoloRunner do
|
|
29
29
|
]
|
30
30
|
end
|
31
31
|
|
32
|
-
it
|
32
|
+
it "defaults the log level to :warn" do
|
33
33
|
described_class.new
|
34
34
|
expect(Chef::Log.level).to eq(:warn)
|
35
35
|
end
|
36
36
|
|
37
|
-
it
|
37
|
+
it "sets the log level" do
|
38
38
|
described_class.new(log_level: :error)
|
39
39
|
expect(Chef::Log.level).to eq(:error)
|
40
40
|
end
|
41
41
|
|
42
|
-
it
|
42
|
+
it "defaults the cookbook_path to the calling spec" do
|
43
43
|
described_class.new
|
44
|
-
expect(Chef::Config.cookbook_path).to eq([File.expand_path(
|
44
|
+
expect(Chef::Config.cookbook_path).to eq([File.expand_path("../../..", __dir__)])
|
45
45
|
end
|
46
46
|
|
47
|
-
it
|
47
|
+
it "defaults the cookbook_path to the calling spec when using windows paths" do
|
48
48
|
runner = described_class.new
|
49
49
|
windows_path = runner.instance_exec(windows_caller_stack) { |callstack|
|
50
50
|
calling_cookbook_path({}, callstack)
|
@@ -55,117 +55,117 @@ describe ChefSpec::SoloRunner do
|
|
55
55
|
expect(windows_path).to end_with("C:/cookbooks")
|
56
56
|
end
|
57
57
|
|
58
|
-
it
|
59
|
-
described_class.new(cookbook_path:
|
60
|
-
expect(Chef::Config.cookbook_path).to eq([
|
58
|
+
it "sets the cookbook path" do
|
59
|
+
described_class.new(cookbook_path: "/tmp/bacon")
|
60
|
+
expect(Chef::Config.cookbook_path).to eq(["/tmp/bacon"])
|
61
61
|
end
|
62
62
|
|
63
|
-
it
|
64
|
-
described_class.new( file_cache_path:
|
65
|
-
expect(Chef::Config.file_cache_path).to eq(
|
63
|
+
it "sets the file cache path" do
|
64
|
+
described_class.new( file_cache_path: "/tmp/pantoa")
|
65
|
+
expect(Chef::Config.file_cache_path).to eq("/tmp/pantoa")
|
66
66
|
end
|
67
67
|
|
68
|
-
it
|
69
|
-
expect(Chef::Config.cache_type).to eq(
|
68
|
+
it "sets the Chef::Config" do
|
69
|
+
expect(Chef::Config.cache_type).to eq("Memory")
|
70
70
|
expect(Chef::Config.force_logger).to be_truthy
|
71
71
|
expect(Chef::Config.no_lazy_load).to be_truthy
|
72
72
|
expect(Chef::Config.solo).to be_truthy
|
73
73
|
expect(Chef::Config.use_policyfile).to be_falsey
|
74
74
|
end
|
75
75
|
|
76
|
-
it
|
76
|
+
it "yields a block to set node attributes" do
|
77
77
|
expect { |block| described_class.new({}, &block) }.to yield_with_args(Chef::Node)
|
78
78
|
end
|
79
79
|
|
80
|
-
context
|
80
|
+
context "default ohai attributes" do
|
81
81
|
let(:hash) { described_class.new.node.to_hash }
|
82
82
|
|
83
|
-
it
|
84
|
-
expect(hash[
|
85
|
-
expect(hash[
|
86
|
-
expect(hash[
|
87
|
-
expect(hash[
|
88
|
-
expect(hash[
|
89
|
-
expect(hash[
|
90
|
-
expect(hash[
|
91
|
-
expect(hash[
|
83
|
+
it "sets the default attributes" do
|
84
|
+
expect(hash["os"]).to eq("chefspec")
|
85
|
+
expect(hash["languages"]["ruby"]["bin_dir"]).to eq("/usr/local/bin")
|
86
|
+
expect(hash["os_version"]).to eq("0.6.1")
|
87
|
+
expect(hash["fqdn"]).to eq("chefspec.local")
|
88
|
+
expect(hash["domain"]).to eq("local")
|
89
|
+
expect(hash["ipaddress"]).to eq("127.0.0.1")
|
90
|
+
expect(hash["hostname"]).to eq("chefspec")
|
91
|
+
expect(hash["kernel"]["machine"]).to eq("i386")
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
95
|
-
context
|
96
|
-
let(:hash) { described_class.new(platform:
|
95
|
+
context "fauxhai attributes" do
|
96
|
+
let(:hash) { described_class.new(platform: "ubuntu", version: "18.04").node.to_hash }
|
97
97
|
|
98
|
-
it
|
99
|
-
expect(hash[
|
100
|
-
expect(hash[
|
101
|
-
expect(hash[
|
102
|
-
expect(hash[
|
103
|
-
expect(hash[
|
104
|
-
expect(hash[
|
105
|
-
expect(hash[
|
106
|
-
expect(hash[
|
98
|
+
it "sets the attributes from fauxhai" do
|
99
|
+
expect(hash["os"]).to eq("linux")
|
100
|
+
expect(hash["languages"]["ruby"]["ruby_bin"]).to eq("/usr/local/bin/ruby")
|
101
|
+
expect(hash["os_version"]).to match(/5.4.0-.*-.*/) # avoid failing when fauxhai data changes
|
102
|
+
expect(hash["fqdn"]).to eq("fauxhai.local")
|
103
|
+
expect(hash["domain"]).to eq("local")
|
104
|
+
expect(hash["ipaddress"]).to eq("10.0.0.2")
|
105
|
+
expect(hash["hostname"]).to eq("Fauxhai")
|
106
|
+
expect(hash["kernel"]["machine"]).to eq("x86_64")
|
107
107
|
end
|
108
108
|
end
|
109
109
|
|
110
|
-
context
|
110
|
+
context "RSpec global configuration" do
|
111
111
|
before do
|
112
|
-
allow(RSpec.configuration).to receive(:cookbook_path).and_return(
|
113
|
-
allow(RSpec.configuration).to receive(:environment_path).and_return(
|
114
|
-
allow(RSpec.configuration).to receive(:file_cache_path).and_return(
|
112
|
+
allow(RSpec.configuration).to receive(:cookbook_path).and_return("./path")
|
113
|
+
allow(RSpec.configuration).to receive(:environment_path).and_return("./env-path")
|
114
|
+
allow(RSpec.configuration).to receive(:file_cache_path).and_return("./file-cache-path")
|
115
115
|
allow(RSpec.configuration).to receive(:log_level).and_return(:fatal)
|
116
|
-
allow(RSpec.configuration).to receive(:path).and_return(
|
117
|
-
allow(RSpec.configuration).to receive(:platform).and_return(
|
118
|
-
allow(RSpec.configuration).to receive(:version).and_return(
|
116
|
+
allow(RSpec.configuration).to receive(:path).and_return("ohai.json")
|
117
|
+
allow(RSpec.configuration).to receive(:platform).and_return("ubuntu")
|
118
|
+
allow(RSpec.configuration).to receive(:version).and_return("12.04")
|
119
119
|
end
|
120
120
|
|
121
|
-
it
|
121
|
+
it "uses the RSpec values" do
|
122
122
|
options = described_class.new.options
|
123
|
-
expect(options[:cookbook_path]).to eq(
|
124
|
-
expect(options[:environment_path]).to eq(
|
125
|
-
expect(options[:file_cache_path]).to eq(
|
123
|
+
expect(options[:cookbook_path]).to eq("./path")
|
124
|
+
expect(options[:environment_path]).to eq("./env-path")
|
125
|
+
expect(options[:file_cache_path]).to eq("./file-cache-path")
|
126
126
|
expect(options[:log_level]).to eq(:fatal)
|
127
|
-
expect(options[:path]).to eq(
|
128
|
-
expect(options[:platform]).to eq(
|
129
|
-
expect(options[:version]).to eq(
|
127
|
+
expect(options[:path]).to eq("ohai.json")
|
128
|
+
expect(options[:platform]).to eq("ubuntu")
|
129
|
+
expect(options[:version]).to eq("12.04")
|
130
130
|
end
|
131
131
|
end
|
132
132
|
end
|
133
133
|
|
134
|
-
describe
|
135
|
-
it
|
134
|
+
describe "#node" do
|
135
|
+
it "returns the Chef::Node" do
|
136
136
|
expect(subject.node).to be_a(Chef::Node)
|
137
137
|
end
|
138
138
|
|
139
|
-
it
|
139
|
+
it "defines a #runner method that returns self" do
|
140
140
|
expect(subject.node.methods).to include(:runner)
|
141
141
|
expect(subject.node.runner).to be(subject)
|
142
142
|
end
|
143
143
|
|
144
|
-
it
|
145
|
-
subject.node.normal[
|
146
|
-
expect(subject.node.bacon).to eq(
|
144
|
+
it "allows attributes to be set on the node" do
|
145
|
+
subject.node.normal["bacon"] = "ham"
|
146
|
+
expect(subject.node.bacon).to eq("ham")
|
147
147
|
end
|
148
148
|
end
|
149
149
|
|
150
|
-
describe
|
151
|
-
it
|
152
|
-
expect(subject.converge(
|
153
|
-
.to eq(
|
150
|
+
describe "#to_s" do
|
151
|
+
it "overrides the default string representation to something readable" do
|
152
|
+
expect(subject.converge("apache2::default").to_s)
|
153
|
+
.to eq("#<ChefSpec::SoloRunner run_list: [recipe[apache2::default]]>")
|
154
154
|
end
|
155
155
|
|
156
|
-
it
|
157
|
-
expect(subject.to_s).to eq(
|
156
|
+
it "is ok when a convergence has not yet taken place" do
|
157
|
+
expect(subject.to_s).to eq("#<ChefSpec::SoloRunner run_list: []>")
|
158
158
|
end
|
159
159
|
|
160
|
-
it
|
161
|
-
expect(subject.converge(
|
162
|
-
.to eq(
|
160
|
+
it "includes the entire run_list" do
|
161
|
+
expect(subject.converge("apache2::default", "apache2::mod_ssl").to_s)
|
162
|
+
.to eq("#<ChefSpec::SoloRunner run_list: [recipe[apache2::default], recipe[apache2::mod_ssl]]>")
|
163
163
|
end
|
164
164
|
|
165
|
-
it
|
166
|
-
[
|
165
|
+
it "has the run_list only for the last convergence" do
|
166
|
+
["mysql::client", "mysql::server"].each { |recipe| subject.converge(recipe) }
|
167
167
|
expect(subject.to_s)
|
168
|
-
.to eq(
|
168
|
+
.to eq("#<ChefSpec::SoloRunner run_list: [recipe[mysql::server]]>")
|
169
169
|
end
|
170
170
|
end
|
171
171
|
end
|