[rubygems/rubygems] Fix typo: eglible -> eligible.
https://github.com/rubygems/rubygems/commit/1e487e1337
This commit is contained in:
parent
798083fac8
commit
0046c67dd8
@ -171,7 +171,7 @@ You can use `i` command instead of `install`.
|
|||||||
|
|
||||||
show_installed
|
show_installed
|
||||||
|
|
||||||
say update_suggestion if eglible_for_update?
|
say update_suggestion if eligible_for_update?
|
||||||
|
|
||||||
terminate_interaction exit_code
|
terminate_interaction exit_code
|
||||||
end
|
end
|
||||||
|
@ -28,9 +28,9 @@ Run `gem update --system #{Gem.latest_rubygems_version}` to update your installa
|
|||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
# Determines if current environment is eglible for update suggestion.
|
# Determines if current environment is eligible for update suggestion.
|
||||||
|
|
||||||
def eglible_for_update?
|
def eligible_for_update?
|
||||||
# explicit opt-out
|
# explicit opt-out
|
||||||
return false if Gem.configuration[:prevent_update_suggestion]
|
return false if Gem.configuration[:prevent_update_suggestion]
|
||||||
return false if ENV["RUBYGEMS_PREVENT_UPDATE_SUGGESTION"]
|
return false if ENV["RUBYGEMS_PREVENT_UPDATE_SUGGESTION"]
|
||||||
@ -53,11 +53,11 @@ Run `gem update --system #{Gem.latest_rubygems_version}` to update your installa
|
|||||||
|
|
||||||
# compare current and latest version, this is the part where
|
# compare current and latest version, this is the part where
|
||||||
# latest rubygems spec is fetched from remote
|
# latest rubygems spec is fetched from remote
|
||||||
(Gem.rubygems_version < Gem.latest_rubygems_version).tap do |eglible|
|
(Gem.rubygems_version < Gem.latest_rubygems_version).tap do |eligible|
|
||||||
# store the time of last successful check into state file
|
# store the time of last successful check into state file
|
||||||
Gem.configuration.last_update_check = check_time
|
Gem.configuration.last_update_check = check_time
|
||||||
|
|
||||||
return eglible
|
return eligible
|
||||||
end
|
end
|
||||||
rescue StandardError # don't block install command on any problem
|
rescue StandardError # don't block install command on any problem
|
||||||
false
|
false
|
||||||
|
@ -1554,7 +1554,7 @@ ERROR: Possible alternatives: non_existent_with_hint
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_suggest_update_if_enabled
|
def test_suggest_update_if_enabled
|
||||||
TestUpdateSuggestion.with_eglible_environment(cmd: @cmd) do
|
TestUpdateSuggestion.with_eligible_environment(cmd: @cmd) do
|
||||||
spec_fetcher do |fetcher|
|
spec_fetcher do |fetcher|
|
||||||
fetcher.gem "a", 2
|
fetcher.gem "a", 2
|
||||||
end
|
end
|
||||||
|
@ -15,13 +15,13 @@ class TestUpdateSuggestion < Gem::TestCase
|
|||||||
@week = 7 * 24 * @minute
|
@week = 7 * 24 * @minute
|
||||||
end
|
end
|
||||||
|
|
||||||
def with_eglible_environment(**params)
|
def with_eligible_environment(**params)
|
||||||
self.class.with_eglible_environment(**params) do
|
self.class.with_eligible_environment(**params) do
|
||||||
yield
|
yield
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.with_eglible_environment(
|
def self.with_eligible_environment(
|
||||||
tty: true,
|
tty: true,
|
||||||
rubygems_version: Gem::Version.new("1.2.3"),
|
rubygems_version: Gem::Version.new("1.2.3"),
|
||||||
latest_rubygems_version: Gem::Version.new("2.0.0"),
|
latest_rubygems_version: Gem::Version.new("2.0.0"),
|
||||||
@ -65,10 +65,10 @@ class TestUpdateSuggestion < Gem::TestCase
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_eglible_for_update
|
def test_eligible_for_update
|
||||||
with_eglible_environment(cmd: @cmd) do
|
with_eligible_environment(cmd: @cmd) do
|
||||||
Time.stub :now, 123_456_789 do
|
Time.stub :now, 123_456_789 do
|
||||||
assert_predicate @cmd, :eglible_for_update?
|
assert_predicate @cmd, :eligible_for_update?
|
||||||
assert_equal 123_456_789, Gem.configuration.last_update_check
|
assert_equal 123_456_789, Gem.configuration.last_update_check
|
||||||
|
|
||||||
# test last check is written to config file
|
# test last check is written to config file
|
||||||
@ -77,29 +77,29 @@ class TestUpdateSuggestion < Gem::TestCase
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_eglible_for_update_is_not_annoying_when_new_version_is_released
|
def test_eligible_for_update_is_not_annoying_when_new_version_is_released
|
||||||
current_version = Gem::Version.new("1.2.0")
|
current_version = Gem::Version.new("1.2.0")
|
||||||
latest_version = current_version
|
latest_version = current_version
|
||||||
|
|
||||||
# checking for first time, it is not eglible since new version
|
# checking for first time, it is not eligible since new version
|
||||||
# is not released yet and stored
|
# is not released yet and stored
|
||||||
with_eglible_environment(cmd: @cmd, rubygems_version: current_version, latest_rubygems_version: latest_version) do
|
with_eligible_environment(cmd: @cmd, rubygems_version: current_version, latest_rubygems_version: latest_version) do
|
||||||
Time.stub :now, @start_time do
|
Time.stub :now, @start_time do
|
||||||
refute_predicate @cmd, :eglible_for_update?
|
refute_predicate @cmd, :eligible_for_update?
|
||||||
assert_equal @start_time, Gem.configuration.last_update_check
|
assert_equal @start_time, Gem.configuration.last_update_check
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# checking next week, it is not eglible since new version
|
# checking next week, it is not eligible since new version
|
||||||
# is not released yet and timestamp is stored
|
# is not released yet and timestamp is stored
|
||||||
with_eglible_environment(
|
with_eligible_environment(
|
||||||
cmd: @cmd,
|
cmd: @cmd,
|
||||||
rubygems_version: current_version,
|
rubygems_version: current_version,
|
||||||
latest_rubygems_version: latest_version,
|
latest_rubygems_version: latest_version,
|
||||||
reset_last_update_check: false
|
reset_last_update_check: false
|
||||||
) do
|
) do
|
||||||
Time.stub :now, @start_time + @week do
|
Time.stub :now, @start_time + @week do
|
||||||
refute_predicate @cmd, :eglible_for_update?
|
refute_predicate @cmd, :eligible_for_update?
|
||||||
assert_equal @start_time + @week, Gem.configuration.last_update_check
|
assert_equal @start_time + @week, Gem.configuration.last_update_check
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -107,103 +107,103 @@ class TestUpdateSuggestion < Gem::TestCase
|
|||||||
# pretend new version is released
|
# pretend new version is released
|
||||||
latest_version = Gem::Version.new("1.3.0")
|
latest_version = Gem::Version.new("1.3.0")
|
||||||
|
|
||||||
# checking later same next week, it is not eglible even new version
|
# checking later same next week, it is not eligible even new version
|
||||||
# is released and timestamp is not stored
|
# is released and timestamp is not stored
|
||||||
with_eglible_environment(
|
with_eligible_environment(
|
||||||
cmd: @cmd,
|
cmd: @cmd,
|
||||||
rubygems_version: current_version,
|
rubygems_version: current_version,
|
||||||
latest_rubygems_version: latest_version,
|
latest_rubygems_version: latest_version,
|
||||||
reset_last_update_check: false
|
reset_last_update_check: false
|
||||||
) do
|
) do
|
||||||
Time.stub :now, @start_time + @week + @minute do
|
Time.stub :now, @start_time + @week + @minute do
|
||||||
refute_predicate @cmd, :eglible_for_update?
|
refute_predicate @cmd, :eligible_for_update?
|
||||||
assert_equal @start_time + @week, Gem.configuration.last_update_check
|
assert_equal @start_time + @week, Gem.configuration.last_update_check
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_eglible_for_update_is_not_annoying_when_not_upgraded
|
def test_eligible_for_update_is_not_annoying_when_not_upgraded
|
||||||
with_eglible_environment(cmd: @cmd) do
|
with_eligible_environment(cmd: @cmd) do
|
||||||
# checking for first time, it is eglible and stored
|
# checking for first time, it is eligible and stored
|
||||||
Time.stub :now, @start_time do
|
Time.stub :now, @start_time do
|
||||||
assert_predicate @cmd, :eglible_for_update?
|
assert_predicate @cmd, :eligible_for_update?
|
||||||
assert_equal @start_time, Gem.configuration.last_update_check
|
assert_equal @start_time, Gem.configuration.last_update_check
|
||||||
end
|
end
|
||||||
|
|
||||||
# checking minute later is not eglible and not stored
|
# checking minute later is not eligible and not stored
|
||||||
Time.stub :now, @start_time + @minute do
|
Time.stub :now, @start_time + @minute do
|
||||||
refute_predicate @cmd, :eglible_for_update?
|
refute_predicate @cmd, :eligible_for_update?
|
||||||
assert_equal @start_time, Gem.configuration.last_update_check
|
assert_equal @start_time, Gem.configuration.last_update_check
|
||||||
end
|
end
|
||||||
|
|
||||||
# checking week later is eglible again and stored
|
# checking week later is eligible again and stored
|
||||||
Time.stub :now, @start_time + @week do
|
Time.stub :now, @start_time + @week do
|
||||||
assert_predicate @cmd, :eglible_for_update?
|
assert_predicate @cmd, :eligible_for_update?
|
||||||
assert_equal @start_time + @week, Gem.configuration.last_update_check
|
assert_equal @start_time + @week, Gem.configuration.last_update_check
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_eglible_for_update_prevent_config
|
def test_eligible_for_update_prevent_config
|
||||||
with_eglible_environment(cmd: @cmd) do
|
with_eligible_environment(cmd: @cmd) do
|
||||||
original_config = Gem.configuration[:prevent_update_suggestion]
|
original_config = Gem.configuration[:prevent_update_suggestion]
|
||||||
Gem.configuration[:prevent_update_suggestion] = true
|
Gem.configuration[:prevent_update_suggestion] = true
|
||||||
refute_predicate @cmd, :eglible_for_update?
|
refute_predicate @cmd, :eligible_for_update?
|
||||||
ensure
|
ensure
|
||||||
Gem.configuration[:prevent_update_suggestion] = original_config
|
Gem.configuration[:prevent_update_suggestion] = original_config
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_eglible_for_update_prevent_env
|
def test_eligible_for_update_prevent_env
|
||||||
with_eglible_environment(cmd: @cmd) do
|
with_eligible_environment(cmd: @cmd) do
|
||||||
original_env = ENV["RUBYGEMS_PREVENT_UPDATE_SUGGESTION"]
|
original_env = ENV["RUBYGEMS_PREVENT_UPDATE_SUGGESTION"]
|
||||||
ENV["RUBYGEMS_PREVENT_UPDATE_SUGGESTION"] = "yes"
|
ENV["RUBYGEMS_PREVENT_UPDATE_SUGGESTION"] = "yes"
|
||||||
refute_predicate @cmd, :eglible_for_update?
|
refute_predicate @cmd, :eligible_for_update?
|
||||||
ensure
|
ensure
|
||||||
ENV["RUBYGEMS_PREVENT_UPDATE_SUGGESTION"] = original_env
|
ENV["RUBYGEMS_PREVENT_UPDATE_SUGGESTION"] = original_env
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_eglible_for_update_non_tty
|
def test_eligible_for_update_non_tty
|
||||||
with_eglible_environment(tty: false, cmd: @cmd) do
|
with_eligible_environment(tty: false, cmd: @cmd) do
|
||||||
refute_predicate @cmd, :eglible_for_update?
|
refute_predicate @cmd, :eligible_for_update?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_eglible_for_update_for_prerelease
|
def test_eligible_for_update_for_prerelease
|
||||||
with_eglible_environment(rubygems_version: Gem::Version.new("1.0.0-rc1"), cmd: @cmd) do
|
with_eligible_environment(rubygems_version: Gem::Version.new("1.0.0-rc1"), cmd: @cmd) do
|
||||||
refute_predicate @cmd, :eglible_for_update?
|
refute_predicate @cmd, :eligible_for_update?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_eglible_for_update_disabled_update
|
def test_eligible_for_update_disabled_update
|
||||||
with_eglible_environment(cmd: @cmd) do
|
with_eligible_environment(cmd: @cmd) do
|
||||||
original_disable = Gem.disable_system_update_message
|
original_disable = Gem.disable_system_update_message
|
||||||
Gem.disable_system_update_message = "disabled"
|
Gem.disable_system_update_message = "disabled"
|
||||||
refute_predicate @cmd, :eglible_for_update?
|
refute_predicate @cmd, :eligible_for_update?
|
||||||
ensure
|
ensure
|
||||||
Gem.disable_system_update_message = original_disable
|
Gem.disable_system_update_message = original_disable
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_eglible_for_update_on_ci
|
def test_eligible_for_update_on_ci
|
||||||
with_eglible_environment(ci: true, cmd: @cmd) do
|
with_eligible_environment(ci: true, cmd: @cmd) do
|
||||||
refute_predicate @cmd, :eglible_for_update?
|
refute_predicate @cmd, :eligible_for_update?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_eglible_for_update_unwrittable_config
|
def test_eligible_for_update_unwrittable_config
|
||||||
with_eglible_environment(cmd: @cmd) do
|
with_eligible_environment(cmd: @cmd) do
|
||||||
Gem.configuration.stub :state_file_writable?, false do
|
Gem.configuration.stub :state_file_writable?, false do
|
||||||
refute_predicate @cmd, :eglible_for_update?
|
refute_predicate @cmd, :eligible_for_update?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_eglible_for_update_notification_delay
|
def test_eligible_for_update_notification_delay
|
||||||
with_eglible_environment(cmd: @cmd) do
|
with_eligible_environment(cmd: @cmd) do
|
||||||
Gem.configuration.last_update_check = Time.now.to_i
|
Gem.configuration.last_update_check = Time.now.to_i
|
||||||
refute_predicate @cmd, :eglible_for_update?
|
refute_predicate @cmd, :eligible_for_update?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user