deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lut...@redhat.com
Subject [PATCH 07/13] CIMI tests: add content_type helper to RestClient::Response
Date Thu, 06 Dec 2012 02:42:51 GMT
From: David Lutterkort <lutter@redhat.com>

---
 tests/cimi/test_helper.rb |    4 ++--
 tests/helpers/common.rb   |    7 +++++++
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/tests/cimi/test_helper.rb b/tests/cimi/test_helper.rb
index bb75f51..6d2b79a 100644
--- a/tests/cimi/test_helper.rb
+++ b/tests/cimi/test_helper.rb
@@ -152,7 +152,7 @@ module CIMI::Test::Methods
     # +resp+
     def model_class(resp)
       resource = nil
-      ct = resp.headers[:content_type]
+      ct = resp.content_type
       if ct == "application/json"
         resp.json["resourceURI"].wont_be_nil
         resource = resp.json["resourceURI"].split("/").last
@@ -460,7 +460,7 @@ class CIMI::Test::Spec < MiniTest::Spec
 
   def retrieve(k, &block)
     response = instance_exec(@format, &block)
-    assert_equal @content_type, response.headers[:content_type]
+    assert_equal @content_type, response.content_type
     if @format == :xml
       response.xml.namespaces["xmlns"].must_equal CIMI::Test::CIMI_NAMESPACE
     end
diff --git a/tests/helpers/common.rb b/tests/helpers/common.rb
index 00266e5..d592904 100644
--- a/tests/helpers/common.rb
+++ b/tests/helpers/common.rb
@@ -23,6 +23,13 @@ require 'base64'
 require 'yaml'
 
 module RestClient::Response
+  # Only return the raw content type without parameters
+  def content_type
+    if headers[:content_type]
+      headers[:content_type].split(";").first
+    end
+  end
+
   def xml
     @xml ||= Nokogiri::XML(body)
   end
-- 
1.7.7.6


Mime
View raw message