From 1dc17e7b2e6814c3a6b476f93df4e8983d0a3e42 Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Sun, 13 May 2018 11:26:10 +0900 Subject: Fix `CustomCops/AssertNot` to allow it to have failure message Follow up of #32605. --- activemodel/test/cases/naming_test.rb | 2 +- activemodel/test/cases/secure_password_test.rb | 22 +++++++++++----------- .../test/cases/validations/validates_test.rb | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) (limited to 'activemodel/test/cases') diff --git a/activemodel/test/cases/naming_test.rb b/activemodel/test/cases/naming_test.rb index 009f1f47af..4693da434c 100644 --- a/activemodel/test/cases/naming_test.rb +++ b/activemodel/test/cases/naming_test.rb @@ -248,7 +248,7 @@ class NamingHelpersTest < ActiveModel::TestCase def test_uncountable assert uncountable?(@uncountable), "Expected 'sheep' to be uncountable" - assert !uncountable?(@klass), "Expected 'contact' to be countable" + assert_not uncountable?(@klass), "Expected 'contact' to be countable" end def test_uncountable_route_key diff --git a/activemodel/test/cases/secure_password_test.rb b/activemodel/test/cases/secure_password_test.rb index 912cb6d5ab..c347aa9b24 100644 --- a/activemodel/test/cases/secure_password_test.rb +++ b/activemodel/test/cases/secure_password_test.rb @@ -49,14 +49,14 @@ class SecurePasswordTest < ActiveModel::TestCase test "create a new user with validation and a blank password" do @user.password = "" - assert !@user.valid?(:create), "user should be invalid" + assert_not @user.valid?(:create), "user should be invalid" assert_equal 1, @user.errors.count assert_equal ["can't be blank"], @user.errors[:password] end test "create a new user with validation and a nil password" do @user.password = nil - assert !@user.valid?(:create), "user should be invalid" + assert_not @user.valid?(:create), "user should be invalid" assert_equal 1, @user.errors.count assert_equal ["can't be blank"], @user.errors[:password] end @@ -64,7 +64,7 @@ class SecurePasswordTest < ActiveModel::TestCase test "create a new user with validation and password length greater than 72" do @user.password = "a" * 73 @user.password_confirmation = "a" * 73 - assert !@user.valid?(:create), "user should be invalid" + assert_not @user.valid?(:create), "user should be invalid" assert_equal 1, @user.errors.count assert_equal ["is too long (maximum is 72 characters)"], @user.errors[:password] end @@ -72,7 +72,7 @@ class SecurePasswordTest < ActiveModel::TestCase test "create a new user with validation and a blank password confirmation" do @user.password = "password" @user.password_confirmation = "" - assert !@user.valid?(:create), "user should be invalid" + assert_not @user.valid?(:create), "user should be invalid" assert_equal 1, @user.errors.count assert_equal ["doesn't match Password"], @user.errors[:password_confirmation] end @@ -86,7 +86,7 @@ class SecurePasswordTest < ActiveModel::TestCase test "create a new user with validation and an incorrect password confirmation" do @user.password = "password" @user.password_confirmation = "something else" - assert !@user.valid?(:create), "user should be invalid" + assert_not @user.valid?(:create), "user should be invalid" assert_equal 1, @user.errors.count assert_equal ["doesn't match Password"], @user.errors[:password_confirmation] end @@ -125,7 +125,7 @@ class SecurePasswordTest < ActiveModel::TestCase test "updating an existing user with validation and a nil password" do @existing_user.password = nil - assert !@existing_user.valid?(:update), "user should be invalid" + assert_not @existing_user.valid?(:update), "user should be invalid" assert_equal 1, @existing_user.errors.count assert_equal ["can't be blank"], @existing_user.errors[:password] end @@ -133,7 +133,7 @@ class SecurePasswordTest < ActiveModel::TestCase test "updating an existing user with validation and password length greater than 72" do @existing_user.password = "a" * 73 @existing_user.password_confirmation = "a" * 73 - assert !@existing_user.valid?(:update), "user should be invalid" + assert_not @existing_user.valid?(:update), "user should be invalid" assert_equal 1, @existing_user.errors.count assert_equal ["is too long (maximum is 72 characters)"], @existing_user.errors[:password] end @@ -141,7 +141,7 @@ class SecurePasswordTest < ActiveModel::TestCase test "updating an existing user with validation and a blank password confirmation" do @existing_user.password = "password" @existing_user.password_confirmation = "" - assert !@existing_user.valid?(:update), "user should be invalid" + assert_not @existing_user.valid?(:update), "user should be invalid" assert_equal 1, @existing_user.errors.count assert_equal ["doesn't match Password"], @existing_user.errors[:password_confirmation] end @@ -155,21 +155,21 @@ class SecurePasswordTest < ActiveModel::TestCase test "updating an existing user with validation and an incorrect password confirmation" do @existing_user.password = "password" @existing_user.password_confirmation = "something else" - assert !@existing_user.valid?(:update), "user should be invalid" + assert_not @existing_user.valid?(:update), "user should be invalid" assert_equal 1, @existing_user.errors.count assert_equal ["doesn't match Password"], @existing_user.errors[:password_confirmation] end test "updating an existing user with validation and a blank password digest" do @existing_user.password_digest = "" - assert !@existing_user.valid?(:update), "user should be invalid" + assert_not @existing_user.valid?(:update), "user should be invalid" assert_equal 1, @existing_user.errors.count assert_equal ["can't be blank"], @existing_user.errors[:password] end test "updating an existing user with validation and a nil password digest" do @existing_user.password_digest = nil - assert !@existing_user.valid?(:update), "user should be invalid" + assert_not @existing_user.valid?(:update), "user should be invalid" assert_equal 1, @existing_user.errors.count assert_equal ["can't be blank"], @existing_user.errors[:password] end diff --git a/activemodel/test/cases/validations/validates_test.rb b/activemodel/test/cases/validations/validates_test.rb index 80c347703a..ae5a875c24 100644 --- a/activemodel/test/cases/validations/validates_test.rb +++ b/activemodel/test/cases/validations/validates_test.rb @@ -19,7 +19,7 @@ class ValidatesTest < ActiveModel::TestCase def test_validates_with_messages_empty Person.validates :title, presence: { message: "" } person = Person.new - assert !person.valid?, "person should not be valid." + assert_not person.valid?, "person should not be valid." end def test_validates_with_built_in_validation -- cgit v1.2.3