summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2014-04-22 17:47:45 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2014-04-22 17:47:45 -0700
commit1d68d201ac65004c90dea55de882239026b9067e (patch)
treee6f7f69188d76cf9c3289dd639f7b09a8e77cde3
parentbd1691730f6d1fbcb5f912155328347983228ef7 (diff)
downloadchef-lcg/chef-rest-specs.tar.gz
adding more func specslcg/chef-rest-specs
-rw-r--r--spec/functional/rest_spec.rb29
-rw-r--r--spec/support/shared/functional/http.rb16
2 files changed, 45 insertions, 0 deletions
diff --git a/spec/functional/rest_spec.rb b/spec/functional/rest_spec.rb
index 7c6b1872ef..29427dd5f4 100644
--- a/spec/functional/rest_spec.rb
+++ b/spec/functional/rest_spec.rb
@@ -91,4 +91,33 @@ describe Chef::REST do
end
it_behaves_like "downloading all the things"
+
+ context "rest endpoints" do
+ it "gets json inflated nodes via get_rest" do
+ nodes = Chef::REST.new("http://localhost:9000").get_rest("nodes")
+ expect(nodes).to be_a(Hash)
+ expect(nodes['foo']).to eql("https://api.opscode.com/organizations/scriptkiddie/nodes/foo")
+ end
+
+ it "gets json inflated nodes via get" do
+ nodes = Chef::REST.new("http://localhost:9000").get("nodes")
+ expect(nodes).to be_a(Hash)
+ expect(nodes['foo']).to eql("https://api.opscode.com/organizations/scriptkiddie/nodes/foo")
+ end
+
+ it "gets raw JSON to a tempfile via get_rest" do
+ tempfile = Chef::REST.new("http://localhost:9000").get_rest("nodes", true)
+ tempfile.close
+ nodes = JSON.parse(IO.read(tempfile.path))
+ expect(nodes['foo']).to eql("https://api.opscode.com/organizations/scriptkiddie/nodes/foo")
+ end
+
+ it "gets raw JSON to a tempfile via get" do
+ tempfile = Chef::REST.new("http://localhost:9000").get("nodes", true)
+ tempfile.close
+ nodes = JSON.parse(IO.read(tempfile.path))
+ expect(nodes['foo']).to eql("https://api.opscode.com/organizations/scriptkiddie/nodes/foo")
+ end
+ end
+
end
diff --git a/spec/support/shared/functional/http.rb b/spec/support/shared/functional/http.rb
index c362ecaa18..d3214b77f1 100644
--- a/spec/support/shared/functional/http.rb
+++ b/spec/support/shared/functional/http.rb
@@ -155,6 +155,22 @@ module ChefHTTPShared
}
)
+ #
+ # RESTful endpoints
+ #
+ json_response = <<-EOF
+{
+ "foo": "https://api.opscode.com/organizations/scriptkiddie/nodes/foo",
+ "bar": "https://api.opscode.com/organizations/scriptkiddie/nodes/bar"
+}
+ EOF
+ @api.get('/nodes', 200, json_response,
+ {
+ 'Content-Type' => 'application/json',
+ 'Content-Length' => json_response.bytesize.to_s,
+ }
+ )
+
end
def stop_tiny_server