Permalink
Browse files

Fixed issue with stubbing requests with request body declared as a ha…

…sh, when json was not required.
  • Loading branch information...
1 parent 622912b commit a7cb4fa58ebb0858d82cc6823eb9b821b42f0261 @bblimke committed Nov 5, 2010
View
@@ -12,6 +12,8 @@
require 'webmock/rspec'
require 'webmock/cucumber'
+* Fixed issue with stubbing requests with request body declared as a hash, when json was not required. Thanks to Erik Michaels-Ober for reporting the issue.
+
## 1.5.0
@@ -1,3 +1,5 @@
+require 'json'
+
module WebMock
class RequestPattern
@@ -6,6 +6,7 @@ def capture_output_from_requiring(libs, additional_code = "")
requires = libs.map { |lib| "require '#{lib}'" }
requires << " require 'addressable/uri'"
requires << " require 'crack'"
+ requires << " require 'json'"
requires = requires.join("; ")
webmock_dir = "#{File.dirname(__FILE__)}/../lib"
vendor_dirs = Dir["#{File.dirname(__FILE__)}/vendor/*/lib"]
View
@@ -14,8 +14,6 @@
require 'network_connection'
-require 'json'
-
RSpec.configure do |config|
config.include WebMock::API
unless NetworkConnection.is_network_available?
@@ -55,7 +53,7 @@ def client_specific_request_string(string)
default_headers = default_client_request_headers(method, has_body)
if default_headers
if string.include?(" with headers")
- current_headers = JSON.parse(string.gsub(/.*with headers (\{[^}]+\}).*/, '\1').gsub("=>",":").gsub("'","\""))
+ current_headers = Crack::JSON.parse(string.gsub(/.*with headers (\{[^}]+\}).*/, '\1').gsub("=>",":").gsub("'","\""))
default_headers = WebMock::Util::Headers.normalize_headers(default_headers)
default_headers.merge!(current_headers)
string.gsub!(/(.*) with headers.*/,'\1')
No changes.
View
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
s.authors = ["Bartosz Blimke"]
- s.date = %q{2010-11-03}
+ s.date = %q{2010-11-05}
s.description = %q{WebMock allows stubbing HTTP requests and setting expectations on HTTP requests.}
s.email = %q{bartosz.blimke@gmail.com}
s.extra_rdoc_files = [
@@ -122,6 +122,7 @@ Gem::Specification.new do |s|
"spec/vendor/addressable/lib/addressable/uri.rb",
"spec/vendor/addressable/lib/uri.rb",
"spec/vendor/crack/lib/crack.rb",
+ "spec/vendor/json/lib/json.rb",
"spec/vendor/right_http_connection-1.2.4/lib/net_fix.rb",
"spec/vendor/right_http_connection-1.2.4/lib/right_http_connection.rb",
"spec/vendor/right_http_connection-1.2.4/setup.rb",

0 comments on commit a7cb4fa

Please sign in to comment.