From 6539877cb02fca8f83b60cd94bc5d40d5558d96e Mon Sep 17 00:00:00 2001 From: Shinichi Maeshima Date: Wed, 18 Jun 2025 17:40:18 +0900 Subject: [PATCH 1/2] Remove the dependency on OpenStruct in the test code When running tests with Ruby 3.4, a warning about OpenStruct is displayed. ``` /Users/willnet/ghq/github.com/Sorcery/sorcery/spec/controllers/controller_oauth_spec.rb:4: warning: ostruct was loaded from the standard library, but will no longer be part of the default gems starting from Ruby 3.5.0. You can add ostruct to your Gemfile or gemspec to silence this warning. ``` Since there was only one place using OpenStruct, I changed the code to avoid using it. --- spec/controllers/controller_oauth_spec.rb | 55 ++++++++++++----------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/spec/controllers/controller_oauth_spec.rb b/spec/controllers/controller_oauth_spec.rb index 5c2a62b6..925bc515 100644 --- a/spec/controllers/controller_oauth_spec.rb +++ b/spec/controllers/controller_oauth_spec.rb @@ -1,39 +1,40 @@ require 'spec_helper' # require 'shared_examples/controller_oauth_shared_examples' -require 'ostruct' def stub_all_oauth_requests! consumer = OAuth::Consumer.new('key', 'secret', site: 'http://myapi.com') req_token = OAuth::RequestToken.new(consumer) acc_token = OAuth::AccessToken.new(consumer) - response = OpenStruct.new - response.body = { - 'following' => false, 'listed_count' => 0, 'profile_link_color' => '0084B4', - 'profile_image_url' => 'http://a1.twimg.com/profile_images/536178575/noamb_normal.jpg', - 'description' => 'Programmer/Heavy Metal Fan/New Father', - 'status' => { - 'text' => 'coming soon to sorcery gem: twitter and facebook authentication support.', - 'truncated' => false, 'favorited' => false, 'source' => 'web', 'geo' => nil, - 'in_reply_to_screen_name' => nil, 'in_reply_to_user_id' => nil, - 'in_reply_to_status_id_str' => nil, 'created_at' => 'Sun Mar 06 23:01:12 +0000 2011', - 'contributors' => nil, 'place' => nil, 'retweeted' => false, 'in_reply_to_status_id' => nil, - 'in_reply_to_user_id_str' => nil, 'coordinates' => nil, 'retweet_count' => 0, - 'id' => 44_533_012_284_706_816, 'id_str' => '44533012284706816' - }, - 'show_all_inline_media' => false, 'geo_enabled' => true, - 'profile_sidebar_border_color' => 'a8c7f7', 'url' => nil, 'followers_count' => 10, - 'screen_name' => 'nbenari', 'profile_use_background_image' => true, 'location' => 'Israel', - 'statuses_count' => 25, 'profile_background_color' => '022330', 'lang' => 'en', - 'verified' => false, 'notifications' => false, - 'profile_background_image_url' => 'http://a3.twimg.com/profile_background_images/104087198/04042010339.jpg', - 'favourites_count' => 5, 'created_at' => 'Fri Nov 20 21:58:19 +0000 2009', - 'is_translator' => false, 'contributors_enabled' => false, 'protected' => false, - 'follow_request_sent' => false, 'time_zone' => 'Greenland', 'profile_text_color' => '333333', - 'name' => 'Noam Ben Ari', 'friends_count' => 10, 'profile_sidebar_fill_color' => 'C0DFEC', - 'id' => 123, 'id_str' => '91434812', 'profile_background_tile' => false, 'utc_offset' => -10_800 - }.to_json + response = Object.new + def response.body + { + 'following' => false, 'listed_count' => 0, 'profile_link_color' => '0084B4', + 'profile_image_url' => 'http://a1.twimg.com/profile_images/536178575/noamb_normal.jpg', + 'description' => 'Programmer/Heavy Metal Fan/New Father', + 'status' => { + 'text' => 'coming soon to sorcery gem: twitter and facebook authentication support.', + 'truncated' => false, 'favorited' => false, 'source' => 'web', 'geo' => nil, + 'in_reply_to_screen_name' => nil, 'in_reply_to_user_id' => nil, + 'in_reply_to_status_id_str' => nil, 'created_at' => 'Sun Mar 06 23:01:12 +0000 2011', + 'contributors' => nil, 'place' => nil, 'retweeted' => false, 'in_reply_to_status_id' => nil, + 'in_reply_to_user_id_str' => nil, 'coordinates' => nil, 'retweet_count' => 0, + 'id' => 44_533_012_284_706_816, 'id_str' => '44533012284706816' + }, + 'show_all_inline_media' => false, 'geo_enabled' => true, + 'profile_sidebar_border_color' => 'a8c7f7', 'url' => nil, 'followers_count' => 10, + 'screen_name' => 'nbenari', 'profile_use_background_image' => true, 'location' => 'Israel', + 'statuses_count' => 25, 'profile_background_color' => '022330', 'lang' => 'en', + 'verified' => false, 'notifications' => false, + 'profile_background_image_url' => 'http://a3.twimg.com/profile_background_images/104087198/04042010339.jpg', + 'favourites_count' => 5, 'created_at' => 'Fri Nov 20 21:58:19 +0000 2009', + 'is_translator' => false, 'contributors_enabled' => false, 'protected' => false, + 'follow_request_sent' => false, 'time_zone' => 'Greenland', 'profile_text_color' => '333333', + 'name' => 'Noam Ben Ari', 'friends_count' => 10, 'profile_sidebar_fill_color' => 'C0DFEC', + 'id' => 123, 'id_str' => '91434812', 'profile_background_tile' => false, 'utc_offset' => -10_800 + }.to_json + end session[:request_token] = req_token.token session[:request_token_secret] = req_token.secret From 81f89439c1dae7deec22192e079e6c0952b35f11 Mon Sep 17 00:00:00 2001 From: Shinichi Maeshima Date: Wed, 18 Jun 2025 19:34:02 +0900 Subject: [PATCH 2/2] Add #382 to Changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index dcb93142..d6642cd6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Changelog ## HEAD +* Remove the dependency on OpenStruct in the test code [#382](https://github.com/Sorcery/sorcery/pull/382) * Add Ruby 3.4 to CI matrix [#381](https://github.com/Sorcery/sorcery/pull/381) * Fix CI failures [#379](https://github.com/Sorcery/sorcery/pull/379) * Fixed minor issues with test to get all green so that we can continue development [#377](https://github.com/Sorcery/sorcery/pull/377)