From a651903a868d2cefd517b3a31025af443a35b8a9 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 21 Jun 2023 17:44:16 +0900 Subject: [PATCH] [rubygems/rubygems] Prefer `assert_predicate` over mere `assert` https://github.com/rubygems/rubygems/commit/0d10063824 --- test/rubygems/test_gem_update_suggestion.rb | 30 ++++++++++----------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/test/rubygems/test_gem_update_suggestion.rb b/test/rubygems/test_gem_update_suggestion.rb index 835a2d84f107fe..57de77e063f71b 100644 --- a/test/rubygems/test_gem_update_suggestion.rb +++ b/test/rubygems/test_gem_update_suggestion.rb @@ -68,7 +68,7 @@ def test_update_suggestion def test_eglible_for_update with_eglible_environment(cmd: @cmd) do Time.stub :now, 123_456_789 do - assert @cmd.eglible_for_update? + assert_predicate @cmd, :eglible_for_update? assert_equal 123_456_789, Gem.configuration.last_update_check # test last check is written to config file @@ -85,7 +85,7 @@ def test_eglible_for_update_is_not_annoying_when_new_version_is_released # is not released yet and stored with_eglible_environment(cmd: @cmd, rubygems_version: current_version, latest_rubygems_version: latest_version) do Time.stub :now, @start_time do - refute @cmd.eglible_for_update? + refute_predicate @cmd, :eglible_for_update? assert_equal @start_time, Gem.configuration.last_update_check end end @@ -99,7 +99,7 @@ def test_eglible_for_update_is_not_annoying_when_new_version_is_released reset_last_update_check: false ) do Time.stub :now, @start_time + @week do - refute @cmd.eglible_for_update? + refute_predicate @cmd, :eglible_for_update? assert_equal @start_time + @week, Gem.configuration.last_update_check end end @@ -116,7 +116,7 @@ def test_eglible_for_update_is_not_annoying_when_new_version_is_released reset_last_update_check: false ) do Time.stub :now, @start_time + @week + @minute do - refute @cmd.eglible_for_update? + refute_predicate @cmd, :eglible_for_update? assert_equal @start_time + @week, Gem.configuration.last_update_check end end @@ -126,19 +126,19 @@ def test_eglible_for_update_is_not_annoying_when_not_upgraded with_eglible_environment(cmd: @cmd) do # checking for first time, it is eglible and stored Time.stub :now, @start_time do - assert @cmd.eglible_for_update? + assert_predicate @cmd, :eglible_for_update? assert_equal @start_time, Gem.configuration.last_update_check end # checking minute later is not eglible and not stored Time.stub :now, @start_time + @minute do - refute @cmd.eglible_for_update? + refute_predicate @cmd, :eglible_for_update? assert_equal @start_time, Gem.configuration.last_update_check end # checking week later is eglible again and stored Time.stub :now, @start_time + @week do - assert @cmd.eglible_for_update? + assert_predicate @cmd, :eglible_for_update? assert_equal @start_time + @week, Gem.configuration.last_update_check end end @@ -148,7 +148,7 @@ def test_eglible_for_update_prevent_config with_eglible_environment(cmd: @cmd) do original_config = Gem.configuration[:prevent_update_suggestion] Gem.configuration[:prevent_update_suggestion] = true - refute @cmd.eglible_for_update? + refute_predicate @cmd, :eglible_for_update? ensure Gem.configuration[:prevent_update_suggestion] = original_config end @@ -158,7 +158,7 @@ def test_eglible_for_update_prevent_env with_eglible_environment(cmd: @cmd) do original_env = ENV["RUBYGEMS_PREVENT_UPDATE_SUGGESTION"] ENV["RUBYGEMS_PREVENT_UPDATE_SUGGESTION"] = "yes" - refute @cmd.eglible_for_update? + refute_predicate @cmd, :eglible_for_update? ensure ENV["RUBYGEMS_PREVENT_UPDATE_SUGGESTION"] = original_env end @@ -166,13 +166,13 @@ def test_eglible_for_update_prevent_env def test_eglible_for_update_non_tty with_eglible_environment(tty: false, cmd: @cmd) do - refute @cmd.eglible_for_update? + refute_predicate @cmd, :eglible_for_update? end end def test_eglible_for_update_for_prerelease with_eglible_environment(rubygems_version: Gem::Version.new("1.0.0-rc1"), cmd: @cmd) do - refute @cmd.eglible_for_update? + refute_predicate @cmd, :eglible_for_update? end end @@ -180,7 +180,7 @@ def test_eglible_for_update_disabled_update with_eglible_environment(cmd: @cmd) do original_disable = Gem.disable_system_update_message Gem.disable_system_update_message = "disabled" - refute @cmd.eglible_for_update? + refute_predicate @cmd, :eglible_for_update? ensure Gem.disable_system_update_message = original_disable end @@ -188,14 +188,14 @@ def test_eglible_for_update_disabled_update def test_eglible_for_update_on_ci with_eglible_environment(ci: true, cmd: @cmd) do - refute @cmd.eglible_for_update? + refute_predicate @cmd, :eglible_for_update? end end def test_eglible_for_update_unwrittable_config with_eglible_environment(cmd: @cmd) do Gem.configuration.stub :state_file_writable?, false do - refute @cmd.eglible_for_update? + refute_predicate @cmd, :eglible_for_update? end end end @@ -203,7 +203,7 @@ def test_eglible_for_update_unwrittable_config def test_eglible_for_update_notification_delay with_eglible_environment(cmd: @cmd) do Gem.configuration.last_update_check = Time.now.to_i - refute @cmd.eglible_for_update? + refute_predicate @cmd, :eglible_for_update? end end end