webmock 1.7.3 → 1.7.4

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.7.4
4
+
5
+ * Added support for matching EM-HTTP-Request requests with body declared as a Hash
6
+
7
+ Thanks to [David Yeu](https://github.com/daveyeu)
8
+
3
9
  ## 1.7.3
4
10
 
5
11
  * Added `Get`, `Post`, `Delete`, `Put`, `Head`, `Option` constants to replaced `Net::HTTP` to make it possible to marshal objects with these constants assigned to properties. This fixed problem with `tvdb_party` gem which serializes HTTParty responses.
data/README.md CHANGED
@@ -646,6 +646,7 @@ People who submitted patches and new features or suggested improvements. Many th
646
646
  * Zach Dennis
647
647
  * Nikita Fedyashev
648
648
  * Lin Jen-Shin
649
+ * David Yeu
649
650
 
650
651
  For a full list of contributors you can visit the
651
652
  [contributors](https://github.com/bblimke/webmock/contributors) page.
@@ -112,10 +112,13 @@ if defined?(EventMachine::HttpRequest)
112
112
 
113
113
  uri.query = encode_query(@req.uri, options[:query]).slice(/\?(.*)/, 1)
114
114
 
115
+ body = options[:body] || options['body']
116
+ body = form_encode_body(body) if body.is_a?(Hash)
117
+
115
118
  WebMock::RequestSignature.new(
116
119
  method.downcase.to_sym,
117
120
  uri.to_s,
118
- :body => (options[:body] || options['body']),
121
+ :body => body,
119
122
  :headers => (options[:head] || options['head'])
120
123
  )
121
124
  end
@@ -163,6 +163,8 @@ if defined?(EventMachine::HttpClient)
163
163
 
164
164
  uri.query = encode_query(@req.uri, query).slice(/\?(.*)/, 1)
165
165
 
166
+ body = form_encode_body(body) if body.is_a?(Hash)
167
+
166
168
  WebMock::RequestSignature.new(
167
169
  method.downcase.to_sym,
168
170
  uri.to_s,
@@ -198,4 +200,4 @@ if defined?(EventMachine::HttpClient)
198
200
  end
199
201
  end
200
202
  end
201
- end
203
+ end
@@ -1,3 +1,3 @@
1
1
  module WebMock
2
- VERSION = '1.7.3' unless defined?(::WebMock::VERSION)
2
+ VERSION = '1.7.4' unless defined?(::WebMock::VERSION)
3
3
  end
@@ -126,6 +126,11 @@ unless RUBY_PLATFORM =~ /java/
126
126
  http_request(:get, "http://www.example.com/?x=3", :query => "a[]=b&a[]=c").body.should == "abc"
127
127
  end
128
128
 
129
+ it "should work when the body is passed as a Hash" do
130
+ stub_http_request(:post, "www.example.com").with(:body => {:a => "1", :b => "2"}).to_return(:body => "ok")
131
+ http_request(:post, "http://www.example.com", :body => {:a => "1", :b => "2"}).body.should == "ok"
132
+ end
133
+
129
134
  describe "mocking EM::HttpClient API" do
130
135
  before do
131
136
  stub_http_request(:get, "www.example.com/")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webmock
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.3
4
+ version: 1.7.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2011-08-17 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: addressable
16
- requirement: &2157028660 !ruby/object:Gem::Requirement
16
+ requirement: &2160447620 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -24,10 +24,10 @@ dependencies:
24
24
  version: 2.2.5
25
25
  type: :runtime
26
26
  prerelease: false
27
- version_requirements: *2157028660
27
+ version_requirements: *2160447620
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: crack
30
- requirement: &2157027840 !ruby/object:Gem::Requirement
30
+ requirement: &2160424420 !ruby/object:Gem::Requirement
31
31
  none: false
32
32
  requirements:
33
33
  - - ! '>='
@@ -35,10 +35,10 @@ dependencies:
35
35
  version: 0.1.7
36
36
  type: :runtime
37
37
  prerelease: false
38
- version_requirements: *2157027840
38
+ version_requirements: *2160424420
39
39
  - !ruby/object:Gem::Dependency
40
40
  name: rspec
41
- requirement: &2157027140 !ruby/object:Gem::Requirement
41
+ requirement: &2160422500 !ruby/object:Gem::Requirement
42
42
  none: false
43
43
  requirements:
44
44
  - - ! '>='
@@ -46,10 +46,10 @@ dependencies:
46
46
  version: 2.0.0
47
47
  type: :development
48
48
  prerelease: false
49
- version_requirements: *2157027140
49
+ version_requirements: *2160422500
50
50
  - !ruby/object:Gem::Dependency
51
51
  name: httpclient
52
- requirement: &2157026140 !ruby/object:Gem::Requirement
52
+ requirement: &2160421560 !ruby/object:Gem::Requirement
53
53
  none: false
54
54
  requirements:
55
55
  - - ! '>='
@@ -57,10 +57,10 @@ dependencies:
57
57
  version: 2.1.5.2
58
58
  type: :development
59
59
  prerelease: false
60
- version_requirements: *2157026140
60
+ version_requirements: *2160421560
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: patron
63
- requirement: &2157025680 !ruby/object:Gem::Requirement
63
+ requirement: &2160420320 !ruby/object:Gem::Requirement
64
64
  none: false
65
65
  requirements:
66
66
  - - ! '>='
@@ -68,10 +68,10 @@ dependencies:
68
68
  version: 0.4.9
69
69
  type: :development
70
70
  prerelease: false
71
- version_requirements: *2157025680
71
+ version_requirements: *2160420320
72
72
  - !ruby/object:Gem::Dependency
73
73
  name: em-http-request
74
- requirement: &2157025180 !ruby/object:Gem::Requirement
74
+ requirement: &2160418840 !ruby/object:Gem::Requirement
75
75
  none: false
76
76
  requirements:
77
77
  - - ! '>='
@@ -79,10 +79,10 @@ dependencies:
79
79
  version: 0.2.14
80
80
  type: :development
81
81
  prerelease: false
82
- version_requirements: *2157025180
82
+ version_requirements: *2160418840
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: curb
85
- requirement: &2157024720 !ruby/object:Gem::Requirement
85
+ requirement: &2160400940 !ruby/object:Gem::Requirement
86
86
  none: false
87
87
  requirements:
88
88
  - - ! '>='
@@ -90,10 +90,10 @@ dependencies:
90
90
  version: 0.7.8
91
91
  type: :development
92
92
  prerelease: false
93
- version_requirements: *2157024720
93
+ version_requirements: *2160400940
94
94
  - !ruby/object:Gem::Dependency
95
95
  name: typhoeus
96
- requirement: &2157024260 !ruby/object:Gem::Requirement
96
+ requirement: &2160400240 !ruby/object:Gem::Requirement
97
97
  none: false
98
98
  requirements:
99
99
  - - ! '>='
@@ -101,10 +101,10 @@ dependencies:
101
101
  version: 0.2.4
102
102
  type: :development
103
103
  prerelease: false
104
- version_requirements: *2157024260
104
+ version_requirements: *2160400240
105
105
  - !ruby/object:Gem::Dependency
106
106
  name: minitest
107
- requirement: &2157023800 !ruby/object:Gem::Requirement
107
+ requirement: &2160399300 !ruby/object:Gem::Requirement
108
108
  none: false
109
109
  requirements:
110
110
  - - ! '>='
@@ -112,10 +112,10 @@ dependencies:
112
112
  version: 2.2.2
113
113
  type: :development
114
114
  prerelease: false
115
- version_requirements: *2157023800
115
+ version_requirements: *2160399300
116
116
  - !ruby/object:Gem::Dependency
117
117
  name: rdoc
118
- requirement: &2157023320 !ruby/object:Gem::Requirement
118
+ requirement: &2160398420 !ruby/object:Gem::Requirement
119
119
  none: false
120
120
  requirements:
121
121
  - - ! '>'
@@ -123,7 +123,7 @@ dependencies:
123
123
  version: 3.5.0
124
124
  type: :development
125
125
  prerelease: false
126
- version_requirements: *2157023320
126
+ version_requirements: *2160398420
127
127
  description: WebMock allows stubbing HTTP requests and setting expectations on HTTP
128
128
  requests.
129
129
  email: