[rubygems/rubygems] Prefer assert_predicate
over mere assert
https://github.com/rubygems/rubygems/commit/0d10063824
This commit is contained in:
parent
67ab8b4346
commit
a651903a86
@ -68,7 +68,7 @@ class TestUpdateSuggestion < Gem::TestCase
|
|||||||
def test_eglible_for_update
|
def test_eglible_for_update
|
||||||
with_eglible_environment(cmd: @cmd) do
|
with_eglible_environment(cmd: @cmd) do
|
||||||
Time.stub :now, 123_456_789 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
|
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
|
||||||
@ -85,7 +85,7 @@ class TestUpdateSuggestion < Gem::TestCase
|
|||||||
# 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_eglible_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 @cmd.eglible_for_update?
|
refute_predicate @cmd, :eglible_for_update?
|
||||||
assert_equal @start_time, Gem.configuration.last_update_check
|
assert_equal @start_time, Gem.configuration.last_update_check
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -99,7 +99,7 @@ class TestUpdateSuggestion < Gem::TestCase
|
|||||||
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 @cmd.eglible_for_update?
|
refute_predicate @cmd, :eglible_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
|
||||||
@ -116,7 +116,7 @@ class TestUpdateSuggestion < Gem::TestCase
|
|||||||
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 @cmd.eglible_for_update?
|
refute_predicate @cmd, :eglible_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
|
||||||
@ -126,19 +126,19 @@ class TestUpdateSuggestion < Gem::TestCase
|
|||||||
with_eglible_environment(cmd: @cmd) do
|
with_eglible_environment(cmd: @cmd) do
|
||||||
# checking for first time, it is eglible and stored
|
# checking for first time, it is eglible and stored
|
||||||
Time.stub :now, @start_time do
|
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
|
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 eglible and not stored
|
||||||
Time.stub :now, @start_time + @minute do
|
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
|
assert_equal @start_time, Gem.configuration.last_update_check
|
||||||
end
|
end
|
||||||
|
|
||||||
# checking week later is eglible again and stored
|
# checking week later is eglible again and stored
|
||||||
Time.stub :now, @start_time + @week do
|
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
|
assert_equal @start_time + @week, Gem.configuration.last_update_check
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -148,7 +148,7 @@ class TestUpdateSuggestion < Gem::TestCase
|
|||||||
with_eglible_environment(cmd: @cmd) do
|
with_eglible_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 @cmd.eglible_for_update?
|
refute_predicate @cmd, :eglible_for_update?
|
||||||
ensure
|
ensure
|
||||||
Gem.configuration[:prevent_update_suggestion] = original_config
|
Gem.configuration[:prevent_update_suggestion] = original_config
|
||||||
end
|
end
|
||||||
@ -158,7 +158,7 @@ class TestUpdateSuggestion < Gem::TestCase
|
|||||||
with_eglible_environment(cmd: @cmd) do
|
with_eglible_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 @cmd.eglible_for_update?
|
refute_predicate @cmd, :eglible_for_update?
|
||||||
ensure
|
ensure
|
||||||
ENV["RUBYGEMS_PREVENT_UPDATE_SUGGESTION"] = original_env
|
ENV["RUBYGEMS_PREVENT_UPDATE_SUGGESTION"] = original_env
|
||||||
end
|
end
|
||||||
@ -166,13 +166,13 @@ class TestUpdateSuggestion < Gem::TestCase
|
|||||||
|
|
||||||
def test_eglible_for_update_non_tty
|
def test_eglible_for_update_non_tty
|
||||||
with_eglible_environment(tty: false, cmd: @cmd) do
|
with_eglible_environment(tty: false, cmd: @cmd) do
|
||||||
refute @cmd.eglible_for_update?
|
refute_predicate @cmd, :eglible_for_update?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_eglible_for_update_for_prerelease
|
def test_eglible_for_update_for_prerelease
|
||||||
with_eglible_environment(rubygems_version: Gem::Version.new("1.0.0-rc1"), cmd: @cmd) do
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -180,7 +180,7 @@ class TestUpdateSuggestion < Gem::TestCase
|
|||||||
with_eglible_environment(cmd: @cmd) do
|
with_eglible_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 @cmd.eglible_for_update?
|
refute_predicate @cmd, :eglible_for_update?
|
||||||
ensure
|
ensure
|
||||||
Gem.disable_system_update_message = original_disable
|
Gem.disable_system_update_message = original_disable
|
||||||
end
|
end
|
||||||
@ -188,14 +188,14 @@ class TestUpdateSuggestion < Gem::TestCase
|
|||||||
|
|
||||||
def test_eglible_for_update_on_ci
|
def test_eglible_for_update_on_ci
|
||||||
with_eglible_environment(ci: true, cmd: @cmd) do
|
with_eglible_environment(ci: true, cmd: @cmd) do
|
||||||
refute @cmd.eglible_for_update?
|
refute_predicate @cmd, :eglible_for_update?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_eglible_for_update_unwrittable_config
|
def test_eglible_for_update_unwrittable_config
|
||||||
with_eglible_environment(cmd: @cmd) do
|
with_eglible_environment(cmd: @cmd) do
|
||||||
Gem.configuration.stub :state_file_writable?, false do
|
Gem.configuration.stub :state_file_writable?, false do
|
||||||
refute @cmd.eglible_for_update?
|
refute_predicate @cmd, :eglible_for_update?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -203,7 +203,7 @@ class TestUpdateSuggestion < Gem::TestCase
|
|||||||
def test_eglible_for_update_notification_delay
|
def test_eglible_for_update_notification_delay
|
||||||
with_eglible_environment(cmd: @cmd) do
|
with_eglible_environment(cmd: @cmd) do
|
||||||
Gem.configuration.last_update_check = Time.now.to_i
|
Gem.configuration.last_update_check = Time.now.to_i
|
||||||
refute @cmd.eglible_for_update?
|
refute_predicate @cmd, :eglible_for_update?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user