From 94333a4c31bd10c1f358c538a167e6a4589bae2d Mon Sep 17 00:00:00 2001 From: Daniel Colson Date: Thu, 25 Jan 2018 18:14:09 -0500 Subject: Use assert_predicate and assert_not_predicate --- railties/test/application/configuration_test.rb | 2 +- .../application/initializers/frameworks_test.rb | 2 +- railties/test/application/loading_test.rb | 8 +++---- railties/test/application/mailer_previews_test.rb | 6 ++--- railties/test/application/runner_test.rb | 4 ++-- railties/test/commands/console_test.rb | 10 ++++---- railties/test/engine_test.rb | 2 +- railties/test/generators/create_migration_test.rb | 2 +- .../test/generators/generated_attribute_test.rb | 12 +++++----- railties/test/generators_test.rb | 2 +- railties/test/paths_test.rb | 28 +++++++++++----------- 11 files changed, 39 insertions(+), 39 deletions(-) (limited to 'railties') diff --git a/railties/test/application/configuration_test.rb b/railties/test/application/configuration_test.rb index 826efc9711..e7fb46a6c5 100644 --- a/railties/test/application/configuration_test.rb +++ b/railties/test/application/configuration_test.rb @@ -94,7 +94,7 @@ module ApplicationTests with_rails_env "development" do app "development" - assert Rails.application.config.log_tags.blank? + assert_predicate Rails.application.config.log_tags, :blank? end end diff --git a/railties/test/application/initializers/frameworks_test.rb b/railties/test/application/initializers/frameworks_test.rb index d2b77bd015..e631318f82 100644 --- a/railties/test/application/initializers/frameworks_test.rb +++ b/railties/test/application/initializers/frameworks_test.rb @@ -266,7 +266,7 @@ module ApplicationTests ActiveRecord::Base.connection RUBY require "#{app_path}/config/environment" - assert !ActiveRecord::Base.connection_pool.active_connection? + assert_not_predicate ActiveRecord::Base.connection_pool, :active_connection? end end end diff --git a/railties/test/application/loading_test.rb b/railties/test/application/loading_test.rb index de1e240fd3..2632dd7cde 100644 --- a/railties/test/application/loading_test.rb +++ b/railties/test/application/loading_test.rb @@ -352,11 +352,11 @@ class LoadingTest < ActiveSupport::TestCase def test_initialize_can_be_called_at_any_time require "#{app_path}/config/application" - assert !Rails.initialized? - assert !Rails.application.initialized? + assert_not_predicate Rails, :initialized? + assert_not_predicate Rails.application, :initialized? Rails.initialize! - assert Rails.initialized? - assert Rails.application.initialized? + assert_predicate Rails, :initialized? + assert_predicate Rails.application, :initialized? end private diff --git a/railties/test/application/mailer_previews_test.rb b/railties/test/application/mailer_previews_test.rb index 288968484c..ba186bda44 100644 --- a/railties/test/application/mailer_previews_test.rb +++ b/railties/test/application/mailer_previews_test.rb @@ -296,7 +296,7 @@ module ApplicationTests test "mailer preview not found" do app("development") get "/rails/mailers/notifier" - assert last_response.not_found? + assert_predicate last_response, :not_found? assert_match "Mailer preview 'notifier' not found", last_response.body end @@ -326,7 +326,7 @@ module ApplicationTests app("development") get "/rails/mailers/notifier/bar" - assert last_response.not_found? + assert_predicate last_response, :not_found? assert_match "Email 'bar' not found in NotifierPreview", last_response.body end @@ -382,7 +382,7 @@ module ApplicationTests app("development") get "/rails/mailers/notifier/foo?part=text%2Fhtml" - assert last_response.not_found? + assert_predicate last_response, :not_found? assert_match "Email part 'text/html' not found in NotifierPreview#foo", last_response.body end diff --git a/railties/test/application/runner_test.rb b/railties/test/application/runner_test.rb index aa5d495c97..8f5f48c281 100644 --- a/railties/test/application/runner_test.rb +++ b/railties/test/application/runner_test.rb @@ -107,13 +107,13 @@ module ApplicationTests def test_runner_detects_syntax_errors output = rails("runner", "puts 'hello world", allow_failure: true) - assert_not $?.success? + assert_not_predicate $?, :success? assert_match "unterminated string meets end of file", output end def test_runner_detects_bad_script_name output = rails("runner", "iuiqwiourowe", allow_failure: true) - assert_not $?.success? + assert_not_predicate $?, :success? assert_match "undefined local variable or method `iuiqwiourowe' for", output end diff --git a/railties/test/commands/console_test.rb b/railties/test/commands/console_test.rb index 45ab8d87ff..b7cdb8229e 100644 --- a/railties/test/commands/console_test.rb +++ b/railties/test/commands/console_test.rb @@ -20,30 +20,30 @@ class Rails::ConsoleTest < ActiveSupport::TestCase def test_sandbox_option console = Rails::Console.new(app, parse_arguments(["--sandbox"])) - assert console.sandbox? + assert_predicate console, :sandbox? end def test_short_version_of_sandbox_option console = Rails::Console.new(app, parse_arguments(["-s"])) - assert console.sandbox? + assert_predicate console, :sandbox? end def test_no_options console = Rails::Console.new(app, parse_arguments([])) - assert !console.sandbox? + assert_not_predicate console, :sandbox? end def test_start start - assert app.console.started? + assert_predicate app.console, :started? assert_match(/Loading \w+ environment \(Rails/, output) end def test_start_with_sandbox start ["--sandbox"] - assert app.console.started? + assert_predicate app.console, :started? assert app.sandbox assert_match(/Loading \w+ environment in sandbox \(Rails/, output) end diff --git a/railties/test/engine_test.rb b/railties/test/engine_test.rb index 4bd8a07085..19379e200c 100644 --- a/railties/test/engine_test.rb +++ b/railties/test/engine_test.rb @@ -11,7 +11,7 @@ class EngineTest < ActiveSupport::TestCase end end - assert !engine.routes? + assert_not_predicate engine, :routes? end def test_application_can_be_subclassed diff --git a/railties/test/generators/create_migration_test.rb b/railties/test/generators/create_migration_test.rb index 3cb7fd6baa..2ae38045c5 100644 --- a/railties/test/generators/create_migration_test.rb +++ b/railties/test/generators/create_migration_test.rb @@ -70,7 +70,7 @@ class CreateMigrationTest < Rails::Generators::TestCase create_migration assert_match(/identical db\/migrate\/1_create_articles\.rb\n/, invoke!) - assert @migration.identical? + assert_predicate @migration, :identical? end def test_invoke_when_exists_not_identical diff --git a/railties/test/generators/generated_attribute_test.rb b/railties/test/generators/generated_attribute_test.rb index c6f7bdeda1..772b4f6f0d 100644 --- a/railties/test/generators/generated_attribute_test.rb +++ b/railties/test/generators/generated_attribute_test.rb @@ -104,25 +104,25 @@ class GeneratedAttributeTest < Rails::Generators::TestCase def test_reference_is_true %w(references belongs_to).each do |attribute_type| - assert create_generated_attribute(attribute_type).reference? + assert_predicate create_generated_attribute(attribute_type), :reference? end end def test_reference_is_false %w(foo bar baz).each do |attribute_type| - assert !create_generated_attribute(attribute_type).reference? + assert_not_predicate create_generated_attribute(attribute_type), :reference? end end def test_polymorphic_reference_is_true %w(references belongs_to).each do |attribute_type| - assert create_generated_attribute("#{attribute_type}{polymorphic}").polymorphic? + assert_predicate create_generated_attribute("#{attribute_type}{polymorphic}"), :polymorphic? end end def test_polymorphic_reference_is_false %w(foo bar baz).each do |attribute_type| - assert !create_generated_attribute("#{attribute_type}{polymorphic}").polymorphic? + assert_not_predicate create_generated_attribute("#{attribute_type}{polymorphic}"), :polymorphic? end end @@ -148,7 +148,7 @@ class GeneratedAttributeTest < Rails::Generators::TestCase att = Rails::Generators::GeneratedAttribute.parse("supplier:references{required}:index") assert_equal "supplier", att.name assert_equal :references, att.type - assert att.has_index? - assert att.required? + assert_predicate att, :has_index? + assert_predicate att, :required? end end diff --git a/railties/test/generators_test.rb b/railties/test/generators_test.rb index 1735804664..4302739c4f 100644 --- a/railties/test/generators_test.rb +++ b/railties/test/generators_test.rb @@ -64,7 +64,7 @@ class GeneratorsTest < Rails::Generators::TestCase assert File.exist?(File.join(@path, "generators", "model_generator.rb")) assert_called_with(Rails::Generators::ModelGenerator, :start, [["Account"], {}]) do warnings = capture(:stderr) { Rails::Generators.invoke :model, ["Account"] } - assert warnings.empty? + assert_predicate warnings, :empty? end end diff --git a/railties/test/paths_test.rb b/railties/test/paths_test.rb index 854b4448a4..9f5bb37c20 100644 --- a/railties/test/paths_test.rb +++ b/railties/test/paths_test.rb @@ -104,7 +104,7 @@ class PathsTest < ActiveSupport::TestCase File.stub(:exist?, true) do @root.add "app", with: "/app" @root["app"].autoload_once! - assert @root["app"].autoload_once? + assert_predicate @root["app"], :autoload_once? assert_includes @root.autoload_once, @root["app"].expanded.first end end @@ -112,17 +112,17 @@ class PathsTest < ActiveSupport::TestCase test "it is possible to remove a path that should be autoloaded only once" do @root["app"] = "/app" @root["app"].autoload_once! - assert @root["app"].autoload_once? + assert_predicate @root["app"], :autoload_once? @root["app"].skip_autoload_once! - assert !@root["app"].autoload_once? + assert_not_predicate @root["app"], :autoload_once? assert_not_includes @root.autoload_once, @root["app"].expanded.first end test "it is possible to add a path without assignment and specify it should be loaded only once" do File.stub(:exist?, true) do @root.add "app", with: "/app", autoload_once: true - assert @root["app"].autoload_once? + assert_predicate @root["app"], :autoload_once? assert_includes @root.autoload_once, "/app" end end @@ -130,7 +130,7 @@ class PathsTest < ActiveSupport::TestCase test "it is possible to add multiple paths without assignment and specify it should be loaded only once" do File.stub(:exist?, true) do @root.add "app", with: ["/app", "/app2"], autoload_once: true - assert @root["app"].autoload_once? + assert_predicate @root["app"], :autoload_once? assert_includes @root.autoload_once, "/app" assert_includes @root.autoload_once, "/app2" end @@ -158,7 +158,7 @@ class PathsTest < ActiveSupport::TestCase File.stub(:exist?, true) do @root["app"] = "/app" @root["app"].eager_load! - assert @root["app"].eager_load? + assert_predicate @root["app"], :eager_load? assert_includes @root.eager_load, @root["app"].to_a.first end end @@ -166,17 +166,17 @@ class PathsTest < ActiveSupport::TestCase test "it is possible to skip a path from eager loading" do @root["app"] = "/app" @root["app"].eager_load! - assert @root["app"].eager_load? + assert_predicate @root["app"], :eager_load? @root["app"].skip_eager_load! - assert !@root["app"].eager_load? + assert_not_predicate @root["app"], :eager_load? assert_not_includes @root.eager_load, @root["app"].to_a.first end test "it is possible to add a path without assignment and mark it as eager" do File.stub(:exist?, true) do @root.add "app", with: "/app", eager_load: true - assert @root["app"].eager_load? + assert_predicate @root["app"], :eager_load? assert_includes @root.eager_load, "/app" end end @@ -184,7 +184,7 @@ class PathsTest < ActiveSupport::TestCase test "it is possible to add multiple paths without assignment and mark them as eager" do File.stub(:exist?, true) do @root.add "app", with: ["/app", "/app2"], eager_load: true - assert @root["app"].eager_load? + assert_predicate @root["app"], :eager_load? assert_includes @root.eager_load, "/app" assert_includes @root.eager_load, "/app2" end @@ -193,8 +193,8 @@ class PathsTest < ActiveSupport::TestCase test "it is possible to create a path without assignment and mark it both as eager and load once" do File.stub(:exist?, true) do @root.add "app", with: "/app", eager_load: true, autoload_once: true - assert @root["app"].eager_load? - assert @root["app"].autoload_once? + assert_predicate @root["app"], :eager_load? + assert_predicate @root["app"], :autoload_once? assert_includes @root.eager_load, "/app" assert_includes @root.autoload_once, "/app" end @@ -254,7 +254,7 @@ class PathsTest < ActiveSupport::TestCase test "a path can be added to the load path on creation" do File.stub(:exist?, true) do @root.add "app", with: "/app", load_path: true - assert @root["app"].load_path? + assert_predicate @root["app"], :load_path? assert_equal ["/app"], @root.load_paths end end @@ -271,7 +271,7 @@ class PathsTest < ActiveSupport::TestCase test "a path can be marked as autoload on creation" do File.stub(:exist?, true) do @root.add "app", with: "/app", autoload: true - assert @root["app"].autoload? + assert_predicate @root["app"], :autoload? assert_equal ["/app"], @root.autoload_paths end end -- cgit v1.2.3