summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrégoire Seux <g.seux@criteo.com>2017-03-01 18:00:31 +0100
committerGrégoire Seux <g.seux@criteo.com>2017-03-06 12:00:35 +0100
commitd51d31cf0c514d353cc6883a4af77c11fe802ee9 (patch)
tree28f0102177e931cd6c1578814e8fd1953da6cb7a
parent215c81dcfee22147a447e4f6846c975215d11679 (diff)
downloadchef-d51d31cf0c514d353cc6883a4af77c11fe802ee9.tar.gz
Ensure ruby nodes are supported in knife serve
Change-Id: I4788cac16864c7eb5a876890e9fe41485af80d46 Signed-off-by: Grégoire Seux <g.seux@criteo.com>
-rw-r--r--lib/chef/chef_fs/chef_fs_data_store.rb2
-rw-r--r--spec/integration/knife/serve_spec.rb22
2 files changed, 17 insertions, 7 deletions
diff --git a/lib/chef/chef_fs/chef_fs_data_store.rb b/lib/chef/chef_fs/chef_fs_data_store.rb
index 03afac18d4..0c8f12f1be 100644
--- a/lib/chef/chef_fs/chef_fs_data_store.rb
+++ b/lib/chef/chef_fs/chef_fs_data_store.rb
@@ -768,7 +768,7 @@ class Chef
end
elsif path.length == 2 && path[0] != "cookbooks"
- path[1] = path[1].gsub(/\.(rb|json)/, '')
+ path[1] = path[1].gsub(/\.(rb|json)/, "")
end
path
diff --git a/spec/integration/knife/serve_spec.rb b/spec/integration/knife/serve_spec.rb
index f03b5b99e8..b0cdd8c070 100644
--- a/spec/integration/knife/serve_spec.rb
+++ b/spec/integration/knife/serve_spec.rb
@@ -54,18 +54,28 @@ describe "knife serve", :workstation do
when_the_repository "also has one of each thing" do
before do
- file "nodes/x.json", { "foo" => "bar" }
+ file "nodes/a_node_in_json.json", { "foo" => "bar" }
+ file "nodes/a_node_in_ruby.rb", "name 'a_node_in_ruby'"
file "roles/a_role_in_json.json", { "foo" => "bar" }
file "roles/a_role_in_ruby.rb", "name 'a_role_in_ruby'"
end
- it "knife serve serves up /nodes/x" do
- with_knife_serve do |api|
- expect(api.get("nodes/x")["name"]).to eq("x")
+ %w{a_node_in_json a_node_in_ruby}.each do |file_type|
+ context file_type do
+ it "knife serve serves up /nodes" do
+ with_knife_serve do |api|
+ expect(api.get("nodes")).to have_key(file_type)
+ end
+ end
+ it "knife serve serves up /nodes/#{file_type}" do
+ with_knife_serve do |api|
+ expect(api.get("nodes/#{file_type}")["name"]).to eq(file_type)
+ end
+ end
end
end
- %w(a_role_in_json a_role_in_ruby).each do |file_type|
+ %w{a_role_in_json a_role_in_ruby}.each do |file_type|
context file_type do
it "knife serve serves up /roles" do
with_knife_serve do |api|
@@ -74,7 +84,7 @@ describe "knife serve", :workstation do
end
it "knife serve serves up /roles/#{file_type}" do
with_knife_serve do |api|
- expect(api.get("roles/#{file_type}")['name']).to eq(file_type)
+ expect(api.get("roles/#{file_type}")["name"]).to eq(file_type)
end
end
end