Skip to content

Commit

Permalink
The default stubbed response body, which is an empty String, is unfro…
Browse files Browse the repository at this point in the history
…zen String.
  • Loading branch information
bblimke committed Feb 5, 2024
1 parent 6e78e31 commit 25934a1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/webmock/response.rb
Expand Up @@ -38,7 +38,7 @@ def headers=(headers)
end

def body
@body || ''
@body || String.new
end

def body=(body)
Expand Down
4 changes: 4 additions & 0 deletions spec/unit/response_spec.rb
Expand Up @@ -101,6 +101,10 @@
expect(@response.body).to eq('')
end

it "should return unfrozen string empty body by default" do
expect(@response.body).to_not be_frozen
end

it "should report body if assigned" do
@response = WebMock::Response.new(body: "abc")
expect(@response.body).to eq("abc")
Expand Down

0 comments on commit 25934a1

Please sign in to comment.