chefspec 8.0.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 +15 -13
- data/lib/chefspec/api/core.rb +3 -3
- data/lib/chefspec/api/described.rb +3 -5
- data/lib/chefspec/api/include_any_recipe.rb +24 -0
- data/lib/chefspec/api/stubs.rb +2 -2
- data/lib/chefspec/api/stubs_for.rb +23 -20
- 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 -13
- 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 +18 -12
- data/lib/chefspec/extensions/chef/resource/freebsd_package.rb +2 -1
- data/lib/chefspec/extensions/chef/run_context/cookbook_compiler.rb +21 -1
- data/lib/chefspec/extensions/chef/securable.rb +1 -1
- data/lib/chefspec/extensions/ohai/system.rb +11 -0
- data/lib/chefspec/file_cache_path_proxy.rb +3 -3
- data/lib/chefspec/formatter.rb +15 -3
- data/lib/chefspec/librarian.rb +7 -6
- data/lib/chefspec/matchers.rb +9 -8
- data/lib/chefspec/matchers/do_nothing_matcher.rb +15 -15
- data/lib/chefspec/matchers/include_any_recipe_matcher.rb +51 -0
- 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/runner.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 +4 -4
- 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 +52 -0
- 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 +16 -12
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
require
|
|
1
|
+
require "spec_helper"
|
|
2
2
|
|
|
3
3
|
describe ChefSpec::ExpectException do
|
|
4
|
-
context
|
|
4
|
+
context "when there have been no `raise_error` matchers" do
|
|
5
5
|
subject { described_class.new(Exception) }
|
|
6
6
|
|
|
7
|
-
it
|
|
7
|
+
it "does not match" do
|
|
8
8
|
allow(RSpec::Matchers::BuiltIn::RaiseError).to receive(:last_run).and_return(nil)
|
|
9
9
|
expect(subject.expected?).to be_falsy
|
|
10
10
|
end
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
-
context
|
|
13
|
+
context "when the last error does not match the expected type" do
|
|
14
14
|
subject { described_class.new(RuntimeError) }
|
|
15
15
|
|
|
16
|
-
it
|
|
17
|
-
last_error = double(
|
|
16
|
+
it "does not match" do
|
|
17
|
+
last_error = double("last error", last_error_for_chefspec: ArgumentError)
|
|
18
18
|
allow(RSpec::Matchers::BuiltIn::RaiseError).to receive(:last_run).and_return(last_error)
|
|
19
19
|
expect(subject.expected?).to be_falsy
|
|
20
20
|
end
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
-
context
|
|
23
|
+
context "when the last error matches the expected type" do
|
|
24
24
|
subject { described_class.new(RuntimeError) }
|
|
25
25
|
|
|
26
|
-
it
|
|
27
|
-
last_error = double(
|
|
26
|
+
it "does not match" do
|
|
27
|
+
last_error = double("last error", last_error_for_chefspec: RuntimeError)
|
|
28
28
|
allow(RSpec::Matchers::BuiltIn::RaiseError).to receive(:last_run).and_return(last_error)
|
|
29
29
|
expect(subject.expected?).to be_truthy
|
|
30
30
|
end
|
data/spec/unit/macros_spec.rb
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
require
|
|
1
|
+
require "spec_helper"
|
|
2
2
|
|
|
3
3
|
describe ChefSpec::API::Stubs do
|
|
4
|
-
describe
|
|
5
|
-
let(:command_stub) { double(
|
|
4
|
+
describe "#stub_command" do
|
|
5
|
+
let(:command_stub) { double("command") }
|
|
6
6
|
|
|
7
|
-
it
|
|
7
|
+
it "adds the command to the command registry" do
|
|
8
8
|
allow(ChefSpec::Stubs::CommandStub).to receive(:new).and_return(command_stub)
|
|
9
9
|
stub_command('echo "hello"')
|
|
10
10
|
|
|
@@ -12,21 +12,21 @@ describe ChefSpec::API::Stubs do
|
|
|
12
12
|
end
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
-
describe
|
|
16
|
-
let(:search_stub) { double(
|
|
15
|
+
describe "#stub_search" do
|
|
16
|
+
let(:search_stub) { double("search") }
|
|
17
17
|
|
|
18
|
-
it
|
|
18
|
+
it "adds the query to the search registry" do
|
|
19
19
|
allow(ChefSpec::Stubs::SearchStub).to receive(:new).and_return(search_stub)
|
|
20
|
-
stub_search(:node,
|
|
20
|
+
stub_search(:node, "*:*")
|
|
21
21
|
|
|
22
22
|
expect(ChefSpec::Stubs::SearchRegistry.stubs).to include(search_stub)
|
|
23
23
|
end
|
|
24
24
|
end
|
|
25
25
|
|
|
26
|
-
describe
|
|
27
|
-
let(:data_bag_stub) { double(
|
|
26
|
+
describe "#stub_data_bag" do
|
|
27
|
+
let(:data_bag_stub) { double("data_bag") }
|
|
28
28
|
|
|
29
|
-
it
|
|
29
|
+
it "adds the query to the data_bag registry" do
|
|
30
30
|
allow(ChefSpec::Stubs::DataBagStub).to receive(:new).and_return(data_bag_stub)
|
|
31
31
|
stub_data_bag(:users)
|
|
32
32
|
|
|
@@ -34,84 +34,84 @@ describe ChefSpec::API::Stubs do
|
|
|
34
34
|
end
|
|
35
35
|
end
|
|
36
36
|
|
|
37
|
-
describe
|
|
38
|
-
let(:data_bag_item_stub) { double(
|
|
37
|
+
describe "#stub_data_bag_item" do
|
|
38
|
+
let(:data_bag_item_stub) { double("data_bag_item") }
|
|
39
39
|
|
|
40
|
-
it
|
|
40
|
+
it "adds the query to the data_bag_item registry" do
|
|
41
41
|
allow(ChefSpec::Stubs::DataBagItemStub).to receive(:new).and_return(data_bag_item_stub)
|
|
42
|
-
stub_data_bag_item(:users,
|
|
42
|
+
stub_data_bag_item(:users, "id")
|
|
43
43
|
|
|
44
44
|
expect(ChefSpec::Stubs::DataBagItemRegistry.stubs).to include(data_bag_item_stub)
|
|
45
45
|
end
|
|
46
46
|
end
|
|
47
47
|
|
|
48
|
-
describe
|
|
49
|
-
it
|
|
48
|
+
describe "#stub_node" do
|
|
49
|
+
it "returns a Chef::Node" do
|
|
50
50
|
expect(stub_node).to be_a(Chef::Node)
|
|
51
51
|
end
|
|
52
52
|
|
|
53
|
-
it
|
|
53
|
+
it "defaults the node name to `node.example`" do
|
|
54
54
|
node = stub_node
|
|
55
|
-
expect(node.name).to eq(
|
|
55
|
+
expect(node.name).to eq("node.example")
|
|
56
56
|
end
|
|
57
57
|
|
|
58
|
-
it
|
|
59
|
-
node = stub_node(
|
|
60
|
-
expect(node.name).to eq(
|
|
58
|
+
it "sets the node name when given" do
|
|
59
|
+
node = stub_node("example.com")
|
|
60
|
+
expect(node.name).to eq("example.com")
|
|
61
61
|
end
|
|
62
62
|
|
|
63
|
-
it
|
|
63
|
+
it "sets the automatic attributes" do
|
|
64
64
|
node = stub_node
|
|
65
65
|
expect(node.automatic).to eq(Fauxhai.mock.data)
|
|
66
66
|
end
|
|
67
67
|
|
|
68
|
-
it
|
|
69
|
-
node = stub_node(
|
|
70
|
-
expect(node[
|
|
68
|
+
it "sets the automatic attributes with ohai overrides" do
|
|
69
|
+
node = stub_node("node.example", ohai: { ipaddress: "1.2.3.4" })
|
|
70
|
+
expect(node["ipaddress"]).to eq("1.2.3.4")
|
|
71
71
|
end
|
|
72
72
|
|
|
73
|
-
it
|
|
74
|
-
node = stub_node(
|
|
75
|
-
expect(node.automatic).to eq(Fauxhai.mock(platform:
|
|
73
|
+
it "sets the automatic attributes for a specific platform and version" do
|
|
74
|
+
node = stub_node("node.example", platform: "ubuntu", version: "18.04")
|
|
75
|
+
expect(node.automatic).to eq(Fauxhai.mock(platform: "ubuntu", version: "18.04").data)
|
|
76
76
|
end
|
|
77
77
|
|
|
78
|
-
it
|
|
79
|
-
allow(File).to receive(:exist?).with(
|
|
80
|
-
allow(File).to receive(:read).with(
|
|
81
|
-
node = stub_node(
|
|
82
|
-
expect(node[
|
|
78
|
+
it "sets the automatic attributes from a JSON data path" do
|
|
79
|
+
allow(File).to receive(:exist?).with("/path/to/json").and_return(true)
|
|
80
|
+
allow(File).to receive(:read).with("/path/to/json").and_return('{ "ipaddress": "1.2.3.4" }')
|
|
81
|
+
node = stub_node("node.example", path: "/path/to/json")
|
|
82
|
+
expect(node["ipaddress"]).to eq("1.2.3.4")
|
|
83
83
|
end
|
|
84
84
|
|
|
85
|
-
it
|
|
85
|
+
it "yields a block" do
|
|
86
86
|
expect { |block| stub_node(&block) }.to yield_with_args(Chef::Node)
|
|
87
87
|
end
|
|
88
88
|
end
|
|
89
89
|
end
|
|
90
90
|
|
|
91
|
-
describe
|
|
92
|
-
describe
|
|
93
|
-
describe
|
|
94
|
-
it
|
|
95
|
-
expect(described_cookbook).to eq(
|
|
91
|
+
describe "nginx::source" do
|
|
92
|
+
describe "#described_cookbook" do
|
|
93
|
+
describe "nginx::source" do
|
|
94
|
+
it "returns the name of the cookbook" do
|
|
95
|
+
expect(described_cookbook).to eq("nginx")
|
|
96
96
|
end
|
|
97
97
|
|
|
98
|
-
context
|
|
99
|
-
it
|
|
100
|
-
expect(described_cookbook).to eq(
|
|
98
|
+
context "in a nested context" do
|
|
99
|
+
it "still returns the name of the cookbook" do
|
|
100
|
+
expect(described_cookbook).to eq("nginx")
|
|
101
101
|
end
|
|
102
102
|
end
|
|
103
103
|
end
|
|
104
104
|
end
|
|
105
105
|
|
|
106
|
-
describe
|
|
107
|
-
describe
|
|
108
|
-
it
|
|
109
|
-
expect(described_recipe).to eq(
|
|
106
|
+
describe "#described_recipe" do
|
|
107
|
+
describe "nginx::source" do
|
|
108
|
+
it "returns the cookbook::recipe" do
|
|
109
|
+
expect(described_recipe).to eq("nginx::source")
|
|
110
110
|
end
|
|
111
111
|
|
|
112
|
-
context
|
|
113
|
-
it
|
|
114
|
-
expect(described_recipe).to eq(
|
|
112
|
+
context "in a nested context" do
|
|
113
|
+
it "still retrns the cookbook::recipe" do
|
|
114
|
+
expect(described_recipe).to eq("nginx::source")
|
|
115
115
|
end
|
|
116
116
|
end
|
|
117
117
|
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
describe ChefSpec::Matchers::IncludeAnyRecipeMatcher do
|
|
4
|
+
let(:node) { double("Chef::Node", run_list: run_list) }
|
|
5
|
+
let(:run_list) { double("Chef::RunList", run_list_items: run_list_items) }
|
|
6
|
+
let(:run_list_items) { [run_list_item_one] }
|
|
7
|
+
let(:run_list_item_one) { double("Chef::RunList::RunListItem", name: "one") }
|
|
8
|
+
let(:run_list_item_two) { double("Chef::RunList::RunListItem", name: "two") }
|
|
9
|
+
let(:loaded_recipes) { %w{one} }
|
|
10
|
+
let(:chef_run) { double("chef run", run_context: { loaded_recipes: loaded_recipes, node: node }) }
|
|
11
|
+
|
|
12
|
+
subject { described_class.new }
|
|
13
|
+
|
|
14
|
+
describe "#failure_message" do
|
|
15
|
+
it "has the right value" do
|
|
16
|
+
subject.matches?(chef_run)
|
|
17
|
+
expect(subject.failure_message).to eq("expected to include any recipe")
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
describe "#failure_message_when_negated" do
|
|
22
|
+
it "has the right value" do
|
|
23
|
+
subject.matches?(chef_run)
|
|
24
|
+
expect(subject.failure_message_when_negated).to eq("expected not to include any recipes")
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
describe "#description" do
|
|
29
|
+
it "has the right value" do
|
|
30
|
+
subject.matches?(chef_run)
|
|
31
|
+
expect(subject.description).to eq("include any recipe")
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
describe "#matches?" do
|
|
36
|
+
context "when 0 recipes are included" do
|
|
37
|
+
let(:loaded_recipes) { %w{one} }
|
|
38
|
+
|
|
39
|
+
it "returns false" do
|
|
40
|
+
expect(subject.matches?(chef_run)).to be false
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
context "when at least one recipe is included" do
|
|
45
|
+
let(:loaded_recipes) { %w{one two} }
|
|
46
|
+
|
|
47
|
+
it "returns true" do
|
|
48
|
+
expect(subject.matches?(chef_run)).to be true
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
require
|
|
1
|
+
require "spec_helper"
|
|
2
2
|
|
|
3
3
|
describe ChefSpec::Matchers::IncludeRecipeMatcher do
|
|
4
|
-
let(:chef_run) { double(
|
|
5
|
-
subject { described_class.new(
|
|
4
|
+
let(:chef_run) { double("chef run", run_context: { loaded_recipes: %w{one two three} }) }
|
|
5
|
+
subject { described_class.new("one::default") }
|
|
6
6
|
|
|
7
|
-
describe
|
|
8
|
-
it
|
|
7
|
+
describe "#failure_message" do
|
|
8
|
+
it "has the right value" do
|
|
9
9
|
subject.matches?(chef_run)
|
|
10
10
|
expect(subject.failure_message)
|
|
11
|
-
.to eq(%q
|
|
11
|
+
.to eq(%q{expected ["one::default", "two::default", "three::default"] to include "one::default"})
|
|
12
12
|
end
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
-
describe
|
|
16
|
-
it
|
|
15
|
+
describe "#failure_message_when_negated" do
|
|
16
|
+
it "has the right value" do
|
|
17
17
|
subject.matches?(chef_run)
|
|
18
18
|
expect(subject.failure_message_when_negated)
|
|
19
|
-
.to eq(%q
|
|
19
|
+
.to eq(%q{expected "one::default" to not be included})
|
|
20
20
|
end
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
-
describe
|
|
24
|
-
it
|
|
23
|
+
describe "#description" do
|
|
24
|
+
it "has the right value" do
|
|
25
25
|
subject.matches?(chef_run)
|
|
26
|
-
expect(subject.description).to eq(%q
|
|
26
|
+
expect(subject.description).to eq(%q{include recipe "one::default"})
|
|
27
27
|
end
|
|
28
28
|
end
|
|
29
29
|
|
|
30
|
-
it
|
|
30
|
+
it "matches when the recipe is included" do
|
|
31
31
|
expect(subject.matches?(chef_run)).to be_truthy
|
|
32
32
|
end
|
|
33
33
|
|
|
34
|
-
it
|
|
35
|
-
failure = described_class.new(
|
|
34
|
+
it "does not match when the recipe is not included" do
|
|
35
|
+
failure = described_class.new("nope")
|
|
36
36
|
expect(failure.matches?(chef_run)).to be_falsy
|
|
37
37
|
end
|
|
38
38
|
end
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
require
|
|
1
|
+
require "spec_helper"
|
|
2
2
|
|
|
3
3
|
describe ChefSpec::Matchers::LinkToMatcher do
|
|
4
|
-
let(:from) {
|
|
5
|
-
let(:to) {
|
|
4
|
+
let(:from) { "/var/www" }
|
|
5
|
+
let(:to) { "/var/html" }
|
|
6
6
|
let(:link) do
|
|
7
7
|
Chef::Resource::Link.new(from).tap do |link|
|
|
8
8
|
link.to(to)
|
|
@@ -11,44 +11,44 @@ describe ChefSpec::Matchers::LinkToMatcher do
|
|
|
11
11
|
end
|
|
12
12
|
subject { described_class.new(to) }
|
|
13
13
|
|
|
14
|
-
describe
|
|
15
|
-
it
|
|
14
|
+
describe "#failure_message" do
|
|
15
|
+
it "has the right value" do
|
|
16
16
|
subject.matches?(link)
|
|
17
17
|
expect(subject.failure_message)
|
|
18
|
-
.to eq(%Q
|
|
18
|
+
.to eq(%Q{expected "link[#{from}]" to link to "#{to}" but was "#{to}"})
|
|
19
19
|
end
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
-
describe
|
|
23
|
-
it
|
|
22
|
+
describe "#failure_message_when_negated" do
|
|
23
|
+
it "has the right value" do
|
|
24
24
|
subject.matches?(link)
|
|
25
25
|
expect(subject.failure_message_when_negated)
|
|
26
|
-
.to eq(%Q
|
|
26
|
+
.to eq(%Q{expected "link[#{from}]" to not link to "#{to}"})
|
|
27
27
|
end
|
|
28
28
|
end
|
|
29
29
|
|
|
30
|
-
describe
|
|
31
|
-
it
|
|
30
|
+
describe "#description" do
|
|
31
|
+
it "has the right value" do
|
|
32
32
|
subject.matches?(link)
|
|
33
|
-
expect(subject.description).to eq(%Q
|
|
33
|
+
expect(subject.description).to eq(%Q{link to "#{to}"})
|
|
34
34
|
end
|
|
35
35
|
end
|
|
36
36
|
|
|
37
|
-
context
|
|
38
|
-
it
|
|
37
|
+
context "when the link is correct" do
|
|
38
|
+
it "matches" do
|
|
39
39
|
expect(subject.matches?(link)).to be_truthy
|
|
40
40
|
end
|
|
41
41
|
|
|
42
|
-
it
|
|
42
|
+
it "adds the link to the coverage report" do
|
|
43
43
|
expect(ChefSpec::Coverage).to receive(:cover!).with(link)
|
|
44
44
|
subject.matches?(link)
|
|
45
45
|
end
|
|
46
46
|
end
|
|
47
47
|
|
|
48
|
-
context
|
|
49
|
-
subject { described_class.new(
|
|
48
|
+
context "when the link is not correct" do
|
|
49
|
+
subject { described_class.new("/nope/bad/path/bro") }
|
|
50
50
|
|
|
51
|
-
it
|
|
51
|
+
it "does not match" do
|
|
52
52
|
expect(subject.matches?(link)).to be_falsy
|
|
53
53
|
end
|
|
54
54
|
end
|
|
@@ -1,40 +1,39 @@
|
|
|
1
|
-
require
|
|
1
|
+
require "spec_helper"
|
|
2
2
|
|
|
3
3
|
describe ChefSpec::Matchers::NotificationsMatcher do
|
|
4
|
-
subject { described_class.new(
|
|
4
|
+
subject { described_class.new("execute[install]") }
|
|
5
5
|
let(:package) do
|
|
6
|
-
double(
|
|
7
|
-
name:
|
|
8
|
-
to_s:
|
|
6
|
+
double("package",
|
|
7
|
+
name: "package",
|
|
8
|
+
to_s: "package[foo]",
|
|
9
9
|
is_a?: true,
|
|
10
10
|
performed_action?: true,
|
|
11
11
|
immediate_notifications: [],
|
|
12
12
|
delayed_notifications: [],
|
|
13
|
-
before_notifications: []
|
|
14
|
-
)
|
|
13
|
+
before_notifications: [])
|
|
15
14
|
end
|
|
16
15
|
|
|
17
|
-
describe
|
|
18
|
-
it
|
|
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 "package[foo]" to notify "execute[install]", but did not.}
|
|
22
21
|
end
|
|
23
22
|
end
|
|
24
23
|
|
|
25
|
-
describe
|
|
26
|
-
it
|
|
24
|
+
describe "#failure_message_when_negated" do
|
|
25
|
+
it "has the right value" do
|
|
27
26
|
subject.matches?(package)
|
|
28
27
|
expect(subject.failure_message_when_negated)
|
|
29
|
-
.to eq
|
|
28
|
+
.to eq %{expected "package[foo]" to not notify "execute[install]", but it did.}
|
|
30
29
|
end
|
|
31
30
|
end
|
|
32
31
|
|
|
33
|
-
describe
|
|
34
|
-
it
|
|
32
|
+
describe "#description" do
|
|
33
|
+
it "has the right value" do
|
|
35
34
|
subject.matches?(package)
|
|
36
35
|
expect(subject.description)
|
|
37
|
-
.to eq
|
|
36
|
+
.to eq %{notify "execute[install]"}
|
|
38
37
|
end
|
|
39
38
|
end
|
|
40
39
|
end
|