Since #331, (v1.16), webmock has supported passing a Pathname as the stubbed response body.
This is fantastic for Rails, since file_fixture helper returns Pathnames.
However, passing Pathname as response body for to_return_json is currently not working.
As of v3.26.1:
stub_request(:post, "https://api.taxjar.com/v2/taxes")
.to_return_json(body: file_fixture("taxjar_tax.json"))
the stubbed response is coming back as the file path (presumably because of:
|
elsif !body.is_a?(String) |
|
body.to_json |
(It's calling .to_json on the Pathname and not going through the IO/.read flow.)
Since #331, (v1.16), webmock has supported passing a
Pathnameas the stubbed response body.This is fantastic for Rails, since
file_fixturehelper returns Pathnames.However, passing Pathname as response body for
to_return_jsonis currently not working.As of v3.26.1:
the stubbed response is coming back as the file path (presumably because of:
webmock/lib/webmock/request_stub.rb
Lines 45 to 46 in 596d8a8
(It's calling .to_json on the Pathname and not going through the IO/.read flow.)