diff --git a/.rubocop.yml b/.rubocop.yml index 510c021..9651cea 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -28,3 +28,6 @@ Metrics/BlockLength: Minitest/EmptyLineBeforeAssertionMethods: Enabled: true + +Minitest/AssertPredicate: + Enabled: true diff --git a/test/integration/hosts_js_test.rb b/test/integration/hosts_js_test.rb index 9819dc4..4b7fc49 100644 --- a/test/integration/hosts_js_test.rb +++ b/test/integration/hosts_js_test.rb @@ -29,10 +29,10 @@ def multiple_actions_div assert page.has_no_selector?('input.host_select_boxes:not(:checked)') # Dropdown visible? - assert multiple_actions_div.find('.dropdown-toggle').visible? + assert_predicate multiple_actions_div.find('.dropdown-toggle'), :visible? multiple_actions_div.find('.dropdown-toggle').click - assert multiple_actions_div.find('ul').visible? + assert_predicate multiple_actions_div.find('ul'), :visible? # Hosts are added to cookie host_ids_on_cookie = JSON.parse(CGI.unescape(get_me_the_cookie('_ForemanSelectedhosts')&.fetch(:value))) @@ -43,7 +43,7 @@ def multiple_actions_div click_on('Change Salt Master') end - assert index_modal.visible?, 'Modal window was shown' + assert_predicate index_modal, :visible?, 'Modal window was shown' page.find('#proxy_proxy_id').find("option[value='#{@host.salt_proxy.id}']").select_option # remove hosts cookie on submit @@ -61,10 +61,10 @@ def multiple_actions_div assert page.has_no_selector?('input.host_select_boxes:not(:checked)') # Dropdown visible? - assert multiple_actions_div.find('.dropdown-toggle').visible? + assert_predicate multiple_actions_div.find('.dropdown-toggle'), :visible? multiple_actions_div.find('.dropdown-toggle').click - assert multiple_actions_div.find('ul').visible? + assert_predicate multiple_actions_div.find('ul'), :visible? # Hosts are added to cookie host_ids_on_cookie = JSON.parse(CGI.unescape(get_me_the_cookie('_ForemanSelectedhosts')&.fetch(:value))) @@ -75,7 +75,7 @@ def multiple_actions_div click_on('Change Salt Environment') end - assert index_modal.visible?, 'Modal window was shown' + assert_predicate index_modal, :visible?, 'Modal window was shown' page.find('#salt_environment_id').find("option[value='#{@host.salt_environment.id}']").select_option # remove hosts cookie on submit diff --git a/test/integration/salt_autosign_test.rb b/test/integration/salt_autosign_test.rb index e0d38f2..e04783e 100644 --- a/test/integration/salt_autosign_test.rb +++ b/test/integration/salt_autosign_test.rb @@ -27,7 +27,7 @@ class SaltKeysTest < ActionDispatch::IntegrationTest test 'index page' do visit smart_proxy_salt_autosign_index_path(smart_proxy_id: @proxy.id) - assert find_link('Keys').visible?, 'Keys is not visible' + assert_predicate find_link('Keys'), :visible?, 'Keys is not visible' assert has_title?("Autosign entries for #{@proxy.hostname}"), 'Page title does not appear' end diff --git a/test/unit/host_extensions_test.rb b/test/unit/host_extensions_test.rb index 3d6ccdc..96f7959 100644 --- a/test/unit/host_extensions_test.rb +++ b/test/unit/host_extensions_test.rb @@ -59,7 +59,7 @@ class HostExtensionsTest < ActiveSupport::TestCase assert_not host.configuration? host.salt_proxy = @proxy - assert host.configuration? + assert_predicate host, :configuration? end context 'autosign handling' do diff --git a/test/unit/hostgroup_extensions_test.rb b/test/unit/hostgroup_extensions_test.rb index 43ffcdb..07547fb 100644 --- a/test/unit/hostgroup_extensions_test.rb +++ b/test/unit/hostgroup_extensions_test.rb @@ -78,7 +78,7 @@ class HostgroupExtensionsTest < ActiveSupport::TestCase child_one = FactoryBot.create :hostgroup, parent: parent child_two = FactoryBot.create :hostgroup, :with_salt_modules, parent: child_one - assert child_two.all_salt_modules.any? + assert_predicate child_two.all_salt_modules, :any? end end end diff --git a/test/unit/report_importer_test.rb b/test/unit/report_importer_test.rb index 60a174a..5824345 100644 --- a/test/unit/report_importer_test.rb +++ b/test/unit/report_importer_test.rb @@ -24,7 +24,7 @@ class ReportImporterTest < ActiveSupport::TestCase HostStatus::ConfigurationStatus.any_instance.stubs(:relevant?).returns(true) ForemanSalt::ReportImporter.import(@report) - assert Host.find_by(name: @host).get_status(HostStatus::ConfigurationStatus).error? + assert_predicate Host.find_by(name: @host).get_status(HostStatus::ConfigurationStatus), :error? end test 'importing report has correct status' do @@ -68,7 +68,7 @@ class ReportImporterTest < ActiveSupport::TestCase HostStatus::ConfigurationStatus.any_instance.stubs(:relevant?).returns(true) ForemanSalt::ReportImporter.import(@report_unhandled) - assert Host.find_by(name: @host).get_status(HostStatus::ConfigurationStatus).error? + assert_predicate Host.find_by(name: @host).get_status(HostStatus::ConfigurationStatus), :error? end end end diff --git a/test/unit/salt_variables_test.rb b/test/unit/salt_variables_test.rb index d651908..a74e085 100644 --- a/test/unit/salt_variables_test.rb +++ b/test/unit/salt_variables_test.rb @@ -10,14 +10,14 @@ class SaltVariablesTest < ActiveSupport::TestCase salt_variable = ForemanSalt::SaltVariable.new(key: 'awesome_key', salt_module_id: @state.id) assert_valid salt_variable - assert salt_variable.salt? + assert_predicate salt_variable, :salt? assert_equal @state.id, salt_variable.salt_module.id end test 'salt variable is referencing a LookupValue' do salt_variable = ForemanSalt::SaltVariable.new(key: 'awesome_key', salt_module_id: @state.id) - assert salt_variable.lookup_values.count.zero? + assert_predicate salt_variable.lookup_values.count, :zero? LookupValue.create(value: '[1.2.3.4,2.3.4.5]', match: 'domain = mydomain.net', lookup_key: salt_variable) assert_equal(1, salt_variable.lookup_values.count)