webmock 1.8.10 → 1.8.11

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.8.11
4
+
5
+ * Fix excon adapter to handle `:body => some_file_object`
6
+
7
+ Thanks to [Myron Marston](https://github.com/myronmarston)
8
+
3
9
  ## 1.8.10
4
10
 
5
11
  * em-http-request fix. After request callbacks are correctly invoked for 3xx responses,
@@ -43,7 +43,16 @@ if defined?(Excon)
43
43
  method = (params.delete(:method) || :get).to_s.downcase.to_sym
44
44
  params[:query] = to_query(params[:query]) if params[:query].is_a?(Hash)
45
45
  uri = Addressable::URI.new(params).to_s
46
- WebMock::RequestSignature.new method, uri, :body => params[:body], :headers => params[:headers]
46
+ WebMock::RequestSignature.new method, uri, :body => body_from(params), :headers => params[:headers]
47
+ end
48
+
49
+ def self.body_from(params)
50
+ body = params[:body]
51
+ return body unless body.respond_to?(:read)
52
+
53
+ contents = body.read
54
+ body.rewind if body.respond_to?(:rewind)
55
+ contents
47
56
  end
48
57
 
49
58
  def self.real_response(mock)
@@ -33,8 +33,10 @@ module WebMock
33
33
  #in case any constants were added to @webMockNetHTTP instead of Net::HTTP
34
34
  #after WebMock was enabled.
35
35
  #i.e Net::HTTP::DigestAuth
36
- (@webMockNetHTTP.constants - OriginalNetHTTP.constants).each do |constant|
37
- OriginalNetHTTP.send(:const_set, constant, @webMockNetHTTP.const_get(constant))
36
+ @webMockNetHTTP.constants.each do |constant|
37
+ if !OriginalNetHTTP.constants.map(&:to_s).include?(constant.to_s)
38
+ OriginalNetHTTP.send(:const_set, constant, @webMockNetHTTP.const_get(constant))
39
+ end
38
40
  end
39
41
  end
40
42
 
@@ -64,7 +66,7 @@ module WebMock
64
66
 
65
67
  if Module.method(:constants).arity != 0
66
68
  def constants(inherit=true)
67
- super + self.superclass.constants(inherit)
69
+ (super + self.superclass.constants(inherit)).uniq
68
70
  end
69
71
  end
70
72
  end
@@ -1,3 +1,3 @@
1
1
  module WebMock
2
- VERSION = '1.8.10' unless defined?(::WebMock::VERSION)
2
+ VERSION = '1.8.11' unless defined?(::WebMock::VERSION)
3
3
  end
@@ -11,5 +11,20 @@ describe "Excon" do
11
11
  Excon.get('http://example.com', :path => "resource/", :query => {:a => 1, :b => 2}).body.should == "abc"
12
12
  end
13
13
 
14
+ let(:file) { File.new(__FILE__) }
15
+ let(:file_contents) { File.new(__FILE__).read }
16
+
17
+ it 'handles file uploads correctly' do
18
+ stub_request(:put, "http://example.com/upload").with(:body => file_contents)
19
+
20
+ yielded_request_body = nil
21
+ WebMock.after_request do |req, res|
22
+ yielded_request_body = req.body
23
+ end
24
+
25
+ Excon.put("http://example.com", :path => "upload", :body => file)
26
+
27
+ yielded_request_body.should eq(file_contents)
28
+ end
14
29
  end
15
30
 
@@ -7,7 +7,7 @@ module ExconSpecHelper
7
7
  uri = Addressable::URI.heuristic_parse(uri)
8
8
  uri = uri.omit(:userinfo).to_s.gsub(' ', '+')
9
9
 
10
- options = options.merge(:method => method) # Dup and merge
10
+ options = options.merge(:method => method, :nonblock => false) # Dup and merge
11
11
  response = Excon.new(uri).request(options, &block)
12
12
 
13
13
  headers = WebMock::Util::Headers.normalize_headers(response.headers)
@@ -92,7 +92,7 @@ describe "Net:HTTP" do
92
92
  WebMock.enable!
93
93
  end
94
94
  it "Net::HTTP should have the same constants" do
95
- orig_consts_number = Net::HTTP.constants.size
95
+ orig_consts_number = WebMock::HttpLibAdapters::NetHttpAdapter::OriginalNetHTTP.constants.size
96
96
  Net::HTTP.send(:const_set, "TEST_CONST", 10)
97
97
  Net::HTTP.constants.size.should == orig_consts_number + 1
98
98
  WebMock.disable!
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webmock
3
3
  version: !ruby/object:Gem::Version
4
- hash: 35
5
- prerelease:
4
+ prerelease: false
6
5
  segments:
7
6
  - 1
8
7
  - 8
9
- - 10
10
- version: 1.8.10
8
+ - 11
9
+ version: 1.8.11
11
10
  platform: ruby
12
11
  authors:
13
12
  - Bartosz Blimke
@@ -15,183 +14,162 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2012-09-09 00:00:00 Z
17
+ date: 2012-09-29 00:00:00 +02:00
18
+ default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
- name: addressable
21
+ type: :runtime
22
22
  version_requirements: &id001 !ruby/object:Gem::Requirement
23
- none: false
24
23
  requirements:
25
24
  - - ">="
26
25
  - !ruby/object:Gem::Version
27
- hash: 9
28
26
  segments:
29
27
  - 2
30
28
  - 2
31
29
  - 7
32
30
  version: 2.2.7
33
- type: :runtime
34
- prerelease: false
31
+ name: addressable
35
32
  requirement: *id001
33
+ prerelease: false
36
34
  - !ruby/object:Gem::Dependency
37
- name: crack
35
+ type: :runtime
38
36
  version_requirements: &id002 !ruby/object:Gem::Requirement
39
- none: false
40
37
  requirements:
41
38
  - - ">="
42
39
  - !ruby/object:Gem::Version
43
- hash: 21
44
40
  segments:
45
41
  - 0
46
42
  - 1
47
43
  - 7
48
44
  version: 0.1.7
49
- type: :runtime
50
- prerelease: false
45
+ name: crack
51
46
  requirement: *id002
47
+ prerelease: false
52
48
  - !ruby/object:Gem::Dependency
53
- name: rspec
49
+ type: :development
54
50
  version_requirements: &id003 !ruby/object:Gem::Requirement
55
- none: false
56
51
  requirements:
57
52
  - - ~>
58
53
  - !ruby/object:Gem::Version
59
- hash: 23
60
54
  segments:
61
55
  - 2
62
56
  - 10
63
57
  version: "2.10"
64
- type: :development
65
- prerelease: false
58
+ name: rspec
66
59
  requirement: *id003
60
+ prerelease: false
67
61
  - !ruby/object:Gem::Dependency
68
- name: httpclient
62
+ type: :development
69
63
  version_requirements: &id004 !ruby/object:Gem::Requirement
70
- none: false
71
64
  requirements:
72
65
  - - ">="
73
66
  - !ruby/object:Gem::Version
74
- hash: 15
75
67
  segments:
76
68
  - 2
77
69
  - 2
78
70
  - 4
79
71
  version: 2.2.4
80
- type: :development
81
- prerelease: false
72
+ name: httpclient
82
73
  requirement: *id004
74
+ prerelease: false
83
75
  - !ruby/object:Gem::Dependency
84
- name: patron
76
+ type: :development
85
77
  version_requirements: &id005 !ruby/object:Gem::Requirement
86
- none: false
87
78
  requirements:
88
79
  - - ">="
89
80
  - !ruby/object:Gem::Version
90
- hash: 43
91
81
  segments:
92
82
  - 0
93
83
  - 4
94
84
  - 18
95
85
  version: 0.4.18
96
- type: :development
97
- prerelease: false
86
+ name: patron
98
87
  requirement: *id005
88
+ prerelease: false
99
89
  - !ruby/object:Gem::Dependency
100
- name: em-http-request
90
+ type: :development
101
91
  version_requirements: &id006 !ruby/object:Gem::Requirement
102
- none: false
103
92
  requirements:
104
93
  - - ">="
105
94
  - !ruby/object:Gem::Version
106
- hash: 19
107
95
  segments:
108
96
  - 1
109
97
  - 0
110
98
  - 2
111
99
  version: 1.0.2
112
- type: :development
113
- prerelease: false
100
+ name: em-http-request
114
101
  requirement: *id006
102
+ prerelease: false
115
103
  - !ruby/object:Gem::Dependency
116
- name: curb
104
+ type: :development
117
105
  version_requirements: &id007 !ruby/object:Gem::Requirement
118
- none: false
119
106
  requirements:
120
107
  - - ">="
121
108
  - !ruby/object:Gem::Version
122
- hash: 63
123
109
  segments:
124
110
  - 0
125
111
  - 8
126
112
  - 0
127
113
  version: 0.8.0
128
- type: :development
129
- prerelease: false
114
+ name: curb
130
115
  requirement: *id007
116
+ prerelease: false
131
117
  - !ruby/object:Gem::Dependency
132
- name: typhoeus
118
+ type: :development
133
119
  version_requirements: &id008 !ruby/object:Gem::Requirement
134
- none: false
135
120
  requirements:
136
121
  - - ">="
137
122
  - !ruby/object:Gem::Version
138
- hash: 21
139
123
  segments:
140
124
  - 0
141
125
  - 3
142
126
  - 3
143
127
  version: 0.3.3
144
- type: :development
145
- prerelease: false
128
+ name: typhoeus
146
129
  requirement: *id008
130
+ prerelease: false
147
131
  - !ruby/object:Gem::Dependency
148
- name: excon
132
+ type: :development
149
133
  version_requirements: &id009 !ruby/object:Gem::Requirement
150
- none: false
151
134
  requirements:
152
135
  - - ">="
153
136
  - !ruby/object:Gem::Version
154
- hash: 51
155
137
  segments:
156
138
  - 0
157
139
  - 11
158
140
  - 0
159
141
  version: 0.11.0
160
- type: :development
161
- prerelease: false
142
+ name: excon
162
143
  requirement: *id009
144
+ prerelease: false
163
145
  - !ruby/object:Gem::Dependency
164
- name: minitest
146
+ type: :development
165
147
  version_requirements: &id010 !ruby/object:Gem::Requirement
166
- none: false
167
148
  requirements:
168
149
  - - ">="
169
150
  - !ruby/object:Gem::Version
170
- hash: 3
171
151
  segments:
172
152
  - 2
173
153
  - 2
174
154
  - 2
175
155
  version: 2.2.2
176
- type: :development
177
- prerelease: false
156
+ name: minitest
178
157
  requirement: *id010
158
+ prerelease: false
179
159
  - !ruby/object:Gem::Dependency
180
- name: rdoc
160
+ type: :development
181
161
  version_requirements: &id011 !ruby/object:Gem::Requirement
182
- none: false
183
162
  requirements:
184
163
  - - ">"
185
164
  - !ruby/object:Gem::Version
186
- hash: 19
187
165
  segments:
188
166
  - 3
189
167
  - 5
190
168
  - 0
191
169
  version: 3.5.0
192
- type: :development
193
- prerelease: false
170
+ name: rdoc
194
171
  requirement: *id011
172
+ prerelease: false
195
173
  description: WebMock allows stubbing HTTP requests and setting expectations on HTTP requests.
196
174
  email:
197
175
  - bartosz.blimke@gmail.com
@@ -317,6 +295,7 @@ files:
317
295
  - test/test_helper.rb
318
296
  - test/test_webmock.rb
319
297
  - webmock.gemspec
298
+ has_rdoc: true
320
299
  homepage: http://github.com/bblimke/webmock
321
300
  licenses: []
322
301
 
@@ -326,27 +305,23 @@ rdoc_options: []
326
305
  require_paths:
327
306
  - lib
328
307
  required_ruby_version: !ruby/object:Gem::Requirement
329
- none: false
330
308
  requirements:
331
309
  - - ">="
332
310
  - !ruby/object:Gem::Version
333
- hash: 3
334
311
  segments:
335
312
  - 0
336
313
  version: "0"
337
314
  required_rubygems_version: !ruby/object:Gem::Requirement
338
- none: false
339
315
  requirements:
340
316
  - - ">="
341
317
  - !ruby/object:Gem::Version
342
- hash: 3
343
318
  segments:
344
319
  - 0
345
320
  version: "0"
346
321
  requirements: []
347
322
 
348
323
  rubyforge_project: webmock
349
- rubygems_version: 1.8.19
324
+ rubygems_version: 1.3.6
350
325
  signing_key:
351
326
  specification_version: 3
352
327
  summary: Library for stubbing HTTP requests in Ruby.