You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltacloud.apache.org by lu...@apache.org on 2012/12/11 04:48:25 UTC

[13/14] git commit: CIMI tests: add content_type helper to RestClient::Response

CIMI tests: add content_type helper to RestClient::Response


Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/32625376
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/32625376
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/32625376

Branch: refs/heads/master
Commit: 326253760e3bb75b2e1cbbd7c77c5f51496d651a
Parents: dbda027
Author: David Lutterkort <lu...@redhat.com>
Authored: Tue Dec 4 22:05:42 2012 -0800
Committer: David Lutterkort <lu...@redhat.com>
Committed: Mon Dec 10 17:08:48 2012 -0800

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


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/32625376/tests/cimi/test_helper.rb
----------------------------------------------------------------------
diff --git a/tests/cimi/test_helper.rb b/tests/cimi/test_helper.rb
index bb75f51..b19dd9e 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
@@ -355,7 +355,7 @@ module CIMI::Test::Methods
               coll.href.must_be_uri "#{root} collection"
               model = fetch(coll.href)
               last_response.code.must_equal 200
-              if last_response.headers[:content_type].eql?("application/json")
+              if last_response.content_type.eql?("application/json")
                 last_response.json["resourceURI"].wont_be_nil
               end
             else
@@ -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

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/32625376/tests/helpers/common.rb
----------------------------------------------------------------------
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