Skip to content

test: don't override Fake::HTTP.new - #72

Merged
kou merged 1 commit into
ruby:masterfrom
kou:fix-test-ruby-4.1
Nov 13, 2026
Merged

kou merged 1 commit into
ruby:masterfrom
kou:fix-test-ruby-4.1

Conversation

@kou

@kou kou commented Nov 2, 2026

Copy link
Copy Markdown
Member

GitHub: fix GH-70

Fake::HTTP.new used Class.method(:new).unbind.bind(self) to bypass Net::HTTP.new. It fails with Ruby 4.1 because Class.method(:new) is a singleton method of Class now:

TypeError: singleton method called for a different object

We don't need to bypass Net::HTTP.new. We can use the default Net::HTTP#initialize and set responses by an attribute writer instead.

Reported by Mamoru TASAKA. Thanks!!!

GitHub: fix rubyGH-70

`Fake::HTTP.new` used `Class.method(:new).unbind.bind(self)` to bypass
`Net::HTTP.new`. It fails with Ruby 4.1 because `Class.method(:new)` is
a singleton method of `Class` now:

```text
TypeError: singleton method called for a different object
```

We don't need to bypass `Net::HTTP.new`. We can use the default
`Net::HTTP#initialize` and set responses by an attribute writer instead.

Reported by Mamoru TASAKA. Thanks!!!

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mtasaka

mtasaka commented Nov 12, 2026

Copy link
Copy Markdown

This patch seems to work with both

  • ruby 4.0.9 (2026-10-23 revision 3e93b23afc) +PRISM [x86_64-linux]
  • ruby 4.1.0dev (2026-11-12 master 45666487ee) +PRISM [x86_64-linux]

@kou

kou commented Nov 13, 2026

Copy link
Copy Markdown
Member Author

Thanks. I'll merge this.

@kou
kou merged commit ec20997 into ruby:master Nov 13, 2026
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Testsuite fails with ruby 4.1.0dev

2 participants