Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

INVESTIGATE: compatibility with Ruby 3 #159

Closed
andypiper opened this issue Jan 6, 2021 · 4 comments
Closed

INVESTIGATE: compatibility with Ruby 3 #159

andypiper opened this issue Jan 6, 2021 · 4 comments

Comments

@andypiper
Copy link
Contributor

Issue to explore and document compatibility between twurl and Ruby v3.

Contributions and PRs are welcomed.

@andypiper andypiper self-assigned this Jan 6, 2021
@andypiper
Copy link
Contributor Author

andypiper commented Jan 6, 2021

The -H option is not working in Ruby 3.0 - suspiciously similar to #154 which was an issue with the -X param.

@andypiper
Copy link
Contributor Author

Rake conformance tests are failing in Ruby 3.0 but work in 2.7.2 (macOS)

@smaeda-ks
Copy link
Collaborator

@andypiper I can help you with that if you need a hand. I think the reason why it stopped working since Ruby 3 is likely due to this bug: ruby/ostruct#23

We indeed rely on the OpenStruct here:
https://github.com/twitter/twurl/blob/master/lib/twurl/cli.rb#L361-L400
and the symptom/condition looks to be similar.

As you can see in that issue link, the fix has been merged into Ruby upstream but they haven't released a new Ruby 3.x.x version yet, so we might need to wait for that. I'm not sure how long it takes, but once it's released and users update their Ruby runtime we probably don't need any particular fixes for Ruby 3.

@smaeda-ks smaeda-ks mentioned this issue Jan 20, 2021
@smaeda-ks
Copy link
Collaborator

opened #161

mishina2228 added a commit to mishina2228/twurl that referenced this issue Apr 14, 2022
The following test cases fail when running CI in Ruby 3.0.

```
  1) Failure:
Twurl::CLI::OptionParsingTest#test_setting_host_updates_to_requested_value [/home/runner/work/twurl/twurl/test/cli_test.rb:214]:
Expected: "localhost:3000"
  Actual: "api.twitter.com"

  2) Failure:
Twurl::CLI::OptionParsingTest#test_setting_proxy_updates_to_requested_value [/home/runner/work/twurl/twurl/test/cli_test.rb:237]:
Expected: "localhost:80"
  Actual: nil

  3) Failure:
Twurl::CLI::OptionParsingTest#test_passing_no_ssl_option_disables_ssl [/home/runner/work/twurl/twurl/test/cli_test.rb:196]:
Expected false to be truthy.

  4) Failure:
Twurl::CLI::OptionParsingTest#test_specifying_a_request_method_extracts_and_normalizes_request_method [/home/runner/work/twurl/twurl/test/cli_test.rb:54]:
Expected: "put"
  Actual: "get"

  5) Failure:
Twurl::CLI::OptionParsingTest#test_protocol_is_stripped_from_host [/home/runner/work/twurl/twurl/test/cli_test.rb:221]:
Expected: "localhost:3000"
  Actual: "api.twitter.com"

  6) Failure:
Twurl::CLI::OptionParsingTest#test_passing_data_and_an_explicit_request_method_uses_the_specified_method [/home/runner/work/twurl/twurl/test/cli_test.rb:148]:
Expected: "delete"
  Actual: "post"

  7) Failure:
Twurl::Options::Test#test_ssl_is_enabled_if_the_protocol_is_https [/home/runner/work/twurl/twurl/test/cli_options_test.rb:18]:
Expected false to be truthy.

  8) Failure:
Twurl::Options::Test#test_base_url_is_built_from_protocol_and_host [/home/runner/work/twurl/twurl/test/cli_options_test.rb:13]:
Expected: "http://api.twitter.com"
  Actual: "https://api.twitter.com"
```

According to twitter#159 (comment),
the cause appears to be a bug in OpenStruct.
The bug was fixed in ruby/ostruct#23, and released as v0.3.3.
smaeda-ks pushed a commit that referenced this issue Apr 15, 2022
* Add GitHub Actions Workflow

* Remove Coveralls as it is not being used

#161 (comment)

* Address changes in RR v3.0.0

Now we need to take the block as a proc, not as an argument.
refs: rr/rr@d6da209#diff-a20b4cc1aac26c32a40206ad0776d4ff528201e97b737b7b3f0be1eb0e12e93dL44-L49

* Require RR v3

* Require OpenStruct v0.3.3+

The following test cases fail when running CI in Ruby 3.0.

```
  1) Failure:
Twurl::CLI::OptionParsingTest#test_setting_host_updates_to_requested_value [/home/runner/work/twurl/twurl/test/cli_test.rb:214]:
Expected: "localhost:3000"
  Actual: "api.twitter.com"

  2) Failure:
Twurl::CLI::OptionParsingTest#test_setting_proxy_updates_to_requested_value [/home/runner/work/twurl/twurl/test/cli_test.rb:237]:
Expected: "localhost:80"
  Actual: nil

  3) Failure:
Twurl::CLI::OptionParsingTest#test_passing_no_ssl_option_disables_ssl [/home/runner/work/twurl/twurl/test/cli_test.rb:196]:
Expected false to be truthy.

  4) Failure:
Twurl::CLI::OptionParsingTest#test_specifying_a_request_method_extracts_and_normalizes_request_method [/home/runner/work/twurl/twurl/test/cli_test.rb:54]:
Expected: "put"
  Actual: "get"

  5) Failure:
Twurl::CLI::OptionParsingTest#test_protocol_is_stripped_from_host [/home/runner/work/twurl/twurl/test/cli_test.rb:221]:
Expected: "localhost:3000"
  Actual: "api.twitter.com"

  6) Failure:
Twurl::CLI::OptionParsingTest#test_passing_data_and_an_explicit_request_method_uses_the_specified_method [/home/runner/work/twurl/twurl/test/cli_test.rb:148]:
Expected: "delete"
  Actual: "post"

  7) Failure:
Twurl::Options::Test#test_ssl_is_enabled_if_the_protocol_is_https [/home/runner/work/twurl/twurl/test/cli_options_test.rb:18]:
Expected false to be truthy.

  8) Failure:
Twurl::Options::Test#test_base_url_is_built_from_protocol_and_host [/home/runner/work/twurl/twurl/test/cli_options_test.rb:13]:
Expected: "http://api.twitter.com"
  Actual: "https://api.twitter.com"
```

According to #159 (comment),
the cause appears to be a bug in OpenStruct.
The bug was fixed in ruby/ostruct#23, and released as v0.3.3.

* Drop support for Ruby 2.4

- OpenStruct v0.3.3+ requires Ruby 2.5+.
- It's already reached EOL on 2020-03-31.

* Migrate CI from Travis CI to GitHub Actions
@andypiper andypiper removed their assignment Dec 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants