mirror of
https://github.com/Fishwaldo/huginn.git
synced 2025-03-15 19:31:26 +00:00
Webmock 2 does not support matching body for multipart/form-data
https://github.com/bblimke/webmock/issues/623
This commit is contained in:
parent
5428a8d5b3
commit
7663698673
1 changed files with 8 additions and 3 deletions
|
@ -158,9 +158,14 @@ describe Agents::PostAgent do
|
|||
it 'makes a multipart request when receiving a file_pointer' do
|
||||
WebMock.reset!
|
||||
stub_request(:post, "http://www.example.com/").
|
||||
with(:body => "-------------RubyMultipartPost\r\nContent-Disposition: form-data; name=\"default\"\r\n\r\nvalue\r\n-------------RubyMultipartPost\r\nContent-Disposition: form-data; name=\"file\"; filename=\"local.path\"\r\nContent-Length: 8\r\nContent-Type: \r\nContent-Transfer-Encoding: binary\r\n\r\ntestdata\r\n-------------RubyMultipartPost--\r\n\r\n",
|
||||
:headers => {'Accept-Encoding'=>'gzip,deflate', 'Content-Length'=>'307', 'Content-Type'=>'multipart/form-data; boundary=-----------RubyMultipartPost', 'User-Agent'=>'Huginn - https://github.com/cantino/huginn'}).
|
||||
to_return(:status => 200, :body => "", :headers => {})
|
||||
with(headers: {
|
||||
'Accept-Encoding' => 'gzip,deflate',
|
||||
'Content-Type' => /\Amultipart\/form-data; boundary=/,
|
||||
'User-Agent' => 'Huginn - https://github.com/cantino/huginn'
|
||||
}) { |request|
|
||||
qboundary = Regexp.quote(request.headers['Content-Type'][/ boundary=(.+)/, 1])
|
||||
/\A--#{qboundary}\r\nContent-Disposition: form-data; name="default"\r\n\r\nvalue\r\n--#{qboundary}\r\nContent-Disposition: form-data; name="file"; filename="local.path"\r\nContent-Length: 8\r\nContent-Type: \r\nContent-Transfer-Encoding: binary\r\n\r\ntestdata\r\n--#{qboundary}--\r\n\r\n\z/ === request.body
|
||||
}.to_return(status: 200, body: "", headers: {})
|
||||
event = Event.new(payload: {file_pointer: {agent_id: 111, file: 'test'}})
|
||||
io_mock = mock()
|
||||
mock(@checker).get_io(event) { StringIO.new("testdata") }
|
||||
|
|
Loading…
Add table
Reference in a new issue