summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2018-03-12 10:09:13 -0700
committerGitHub <noreply@github.com>2018-03-12 10:09:13 -0700
commit7722bd6254128039f11d0226327dba729149dc16 (patch)
tree3b3aed4acae7ecd16b87352974030867c9b1a6bc /spec
parente4d89c495a1d853b4340804c111b8c26231f2e2f (diff)
parenta09fa9c514539a49edd7115917aa79d4ad49976f (diff)
downloadchef-7722bd6254128039f11d0226327dba729149dc16.tar.gz
Merge pull request #6967 from chef/tm/chef_environment
RFC 106: expose name and chef_environment as attrs
Diffstat (limited to 'spec')
-rw-r--r--spec/unit/knife/core/node_editor_spec.rb8
-rw-r--r--spec/unit/knife/node_edit_spec.rb4
-rw-r--r--spec/unit/node_spec.rb3
-rw-r--r--spec/unit/policy_builder/policyfile_spec.rb5
4 files changed, 14 insertions, 6 deletions
diff --git a/spec/unit/knife/core/node_editor_spec.rb b/spec/unit/knife/core/node_editor_spec.rb
index 7e05f99f52..a3dd63177d 100644
--- a/spec/unit/knife/core/node_editor_spec.rb
+++ b/spec/unit/knife/core/node_editor_spec.rb
@@ -100,10 +100,10 @@ describe Chef::Knife::NodeEditor do
expect(updated_node).to be_a(Chef::Node)
# Expected to have been changed
- expect(updated_node.chef_environment).to eql(updated_data["chef_environment"])
expect(updated_node.normal_attrs).to eql(updated_data["normal"])
expect(updated_node.policy_name).to eql(updated_data["policy_name"])
expect(updated_node.policy_group).to eql(updated_data["policy_group"])
+ expect(updated_node.chef_environment).to eql(updated_data["policy_group"])
expect(updated_node.run_list.map(&:to_s)).to eql(updated_data["run_list"])
# Expected not to have changed
@@ -131,7 +131,7 @@ describe Chef::Knife::NodeEditor do
updated_node = subject.apply_updates(updated_data)
expect(updated_node).to be_a(Chef::Node)
- expect(updated_node.chef_environment).to eql(updated_data["chef_environment"])
+ expect(updated_node.chef_environment).to eql(updated_data["policy_group"])
expect(updated_node.automatic_attrs).to eql(updated_data["automatic"])
expect(updated_node.normal_attrs).to eql(updated_data["normal"])
expect(updated_node.default_attrs).to eql(updated_data["default"])
@@ -173,7 +173,7 @@ describe Chef::Knife::NodeEditor do
end
it "returns an array of the changed property names" do
- expect(subject.updated?).to eql %w{ normal policy_name policy_group run_list }
+ expect(subject.updated?).to eql %w{ chef_environment normal policy_name policy_group run_list }
end
end
@@ -190,7 +190,7 @@ describe Chef::Knife::NodeEditor do
it "returns an array of property names that doesn't include " +
"the non-editable properties" do
- expect(subject.updated?).to eql %w{ normal policy_name policy_group run_list }
+ expect(subject.updated?).to eql %w{ chef_environment normal policy_name policy_group run_list }
end
end
end
diff --git a/spec/unit/knife/node_edit_spec.rb b/spec/unit/knife/node_edit_spec.rb
index dedb5c949d..e5fa9317b1 100644
--- a/spec/unit/knife/node_edit_spec.rb
+++ b/spec/unit/knife/node_edit_spec.rb
@@ -23,7 +23,7 @@ describe Chef::Knife::NodeEdit do
# helper to convert the view from Chef objects into Ruby objects representing JSON
def deserialized_json_view
- actual = Chef::JSONCompat.from_json(Chef::JSONCompat.to_json_pretty(@knife.node_editor.send(:view)))
+ Chef::JSONCompat.from_json(Chef::JSONCompat.to_json_pretty(@knife.node_editor.send(:view)))
end
before(:each) do
@@ -45,6 +45,8 @@ describe Chef::Knife::NodeEdit do
describe "after loading the node" do
before do
+ @knife.config[:all_attributes] = false
+
allow(@knife).to receive(:node).and_return(@node)
@node.automatic_attrs = { :go => :away }
@node.default_attrs = { :hide => :me }
diff --git a/spec/unit/node_spec.rb b/spec/unit/node_spec.rb
index 2019f1ac42..df85b79fc5 100644
--- a/spec/unit/node_spec.rb
+++ b/spec/unit/node_spec.rb
@@ -186,7 +186,7 @@ describe Chef::Node do
expect { node.policy_group = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqurstuvwxyz0123456789-_:." }.to_not raise_error
end
- it "sets an environment with chef_environment(something)" do
+ it "sets a policy_group with policy_group(something)" do
node.policy_group("staging")
expect(node.policy_group).to eq("staging")
end
@@ -1353,6 +1353,7 @@ describe Chef::Node do
expect(round_tripped_node.policy_name).to eq("my-application")
expect(round_tripped_node.policy_group).to eq("staging")
+ expect(round_tripped_node.chef_environment).to eq("staging")
end
end
diff --git a/spec/unit/policy_builder/policyfile_spec.rb b/spec/unit/policy_builder/policyfile_spec.rb
index b8cf56750d..5663cb8b19 100644
--- a/spec/unit/policy_builder/policyfile_spec.rb
+++ b/spec/unit/policy_builder/policyfile_spec.rb
@@ -574,6 +574,10 @@ describe Chef::PolicyBuilder::Policyfile do
expect(Chef::Config[:policy_group]).to eq("policy_group_from_node_json")
expect(node.policy_name).to eq("policy_name_from_node_json")
expect(node.policy_group).to eq("policy_group_from_node_json")
+ expect(node.automatic_attrs[:policy_name]).to eq("policy_name_from_node_json")
+ expect(node.automatic_attrs[:policy_group]).to eq("policy_group_from_node_json")
+ expect(node.automatic_attrs[:chef_environment]).to eq("policy_group_from_node_json")
+
end
end
@@ -623,6 +627,7 @@ describe Chef::PolicyBuilder::Policyfile do
it "create node.automatic_attrs[:recipes]" do
expect(node.automatic_attrs[:recipes]).to eq(["example1::default", "example2::server"])
end
+
end
context "when a named run_list is given" do