title: How do I prevent hash from escaping strings?
body: <p>I have the following code that generates a hash used for testing the authentication of a internal Restful API.</p>
  
  <p>The problem is the generated hash is returning escaped values.</p>
  
  <p>The <code>json_headers</code> method should return something like this:</p>
  
  <pre><code>{"Authorization"=&gt;"Basic ZnBfZXJwOllrdGh4aHRSZTZWM1d1d09oeVlmcW0xTg==", "Accept"=&gt;"application/json"} 
  </code></pre>
  
  <p>But is returning:</p>
  
  <pre><code>{\"Authorization\"=&gt;\"Basic ZnBfZXJwOllrdGh4aHRSZTZWM1d1d09oeVlmcW0xTg==\\n\", \"Accept\"=&gt;\"application/json\"}
  </code></pre>
  
  <p>Does anyone know an easy way to return raw key/values from a Ruby hash?</p>
  
  <p>Here is the code:</p>
  
  <pre><code>module ERP
    class CustomersMock
  
      def json_headers
        authorization_hash.merge("Accept"=&gt;"application/json")
      end
  
      def authorization_hash 
        {"Authorization" =&gt; "Basic #{base64_user_pass}"}
      end
  
      def user_pass
         # user:password
         [ ERP_CONF['user'], ERP_CONF['password'] ].join(':')
      end
  
      def base64_user_pass
        Base64.encode64(user_pass)
      end
  
      def add(customer)
        customers &lt;&lt; customer
      end        
  
      def customers
        []
      end         
  
      def run
        ActiveResource::HttpMock.respond_to do |mock|
          customers.each do |customer|
            mock.get "/customers/#{customer.id}.json", json_headers, customer.to_json
          end
        end
      end
    end
  end
  </code></pre>
  
  <p>For some reason, if I hard-code the headers hash in place, they work, but if I call the <code>json_headers</code> method, the <code>respond_to</code> block converts them to a string and escapes the values.</p>
  
  <p>Here is the rspec failure:</p>
  
  <pre><code>Could not find a response recorded for &lt;GET: /api/customers/1011.json [{"Authorization"=&gt;"Basic ZnBfZXJwOllrdGh4aHRSZTZWM1d1d09oeVlmcW0xTg==", "Accept"=&gt;"application/json"}] ()&gt; - Responses recorded are: ["&lt;GET: /api/customers/1011.json [{\"Authorization\"=&gt;\"Basic ZnBfZXJwOllrdGh4aHRSZTZWM1d1d09oeVlmcW0xTg==\\n\", \"Accept\"=&gt;\"application/json\"}] ()&gt;"]
  </code></pre>