Parsing JSON parameters when Content-Type: application/json; charset=utf8 #183

Closed
costi opened this Issue May 16, 2012 · 2 comments

3 participants

@costi

I created a failing test test:

require 'rubygems'
require 'webmock'
require 'rest_client'
require 'rspec'

include WebMock::API

describe 'webmock' do 
  before :each do 
    WebMock.disable_net_connect!
    stub_http_request(:post, "www.example.com").with(:body => {:data => {:a => '1', :b => 'five'}})
  end

  it 'should match on JSON body' do
    lambda {
      RestClient.post('www.example.com', '{"data":{"a":"1","b":"five"}}',
                     :content_type => 'application/json')    # ===> Success
    }.should_not raise_error(WebMock::NetConnectNotAllowedError)

  end


  it 'should match on JSON body even if we have charset=utf-8 on the content-type header' do 
    lambda {
      RestClient.post('www.example.com', '{"data":{"a":"1","b":"five"}}',
                     :content_type => 'application/json; charset=utf-8')    # ===> Failure
    }.should_not raise_error(WebMock::NetConnectNotAllowedError)
  end
end
@bblimke
Owner

Thanks. I'll try to fix it sometime this week.

@kjg

pull #194 fixes this

@bblimke bblimke closed this Jul 23, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment