aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel
diff options
context:
space:
mode:
authorDaniel Colson <danieljamescolson@gmail.com>2018-01-25 18:16:57 -0500
committerDaniel Colson <danieljamescolson@gmail.com>2018-01-25 23:32:59 -0500
commit82c39e1a0b5114e2d89a80883a41090567a83196 (patch)
tree476f620e0224130ca3dca3ed4e9b5a58fb0d5da9 /activemodel
parent94333a4c31bd10c1f358c538a167e6a4589bae2d (diff)
downloadrails-82c39e1a0b5114e2d89a80883a41090567a83196.tar.gz
rails-82c39e1a0b5114e2d89a80883a41090567a83196.tar.bz2
rails-82c39e1a0b5114e2d89a80883a41090567a83196.zip
Use assert_empty and assert_not_empty
Diffstat (limited to 'activemodel')
-rw-r--r--activemodel/test/cases/errors_test.rb6
-rw-r--r--activemodel/test/cases/validations/format_validation_test.rb8
-rw-r--r--activemodel/test/cases/validations/with_validation_test.rb10
-rw-r--r--activemodel/test/cases/validations_test.rb4
4 files changed, 14 insertions, 14 deletions
diff --git a/activemodel/test/cases/errors_test.rb b/activemodel/test/cases/errors_test.rb
index 7d155170d3..fe351f922d 100644
--- a/activemodel/test/cases/errors_test.rb
+++ b/activemodel/test/cases/errors_test.rb
@@ -83,7 +83,7 @@ class ErrorsTest < ActiveModel::TestCase
assert_equal 1, person.errors.count
person.errors.clear
- assert_predicate person.errors, :empty?
+ assert_empty person.errors
end
test "error access is indifferent" do
@@ -128,7 +128,7 @@ class ErrorsTest < ActiveModel::TestCase
test "detecting whether there are errors with empty?, blank?, include?" do
person = Person.new
person.errors[:foo]
- assert_predicate person.errors, :empty?
+ assert_empty person.errors
assert_predicate person.errors, :blank?
assert_not_includes person.errors, :foo
end
@@ -371,7 +371,7 @@ class ErrorsTest < ActiveModel::TestCase
assert_equal 1, person.errors.details.count
person.errors.clear
- assert_predicate person.errors.details, :empty?
+ assert_empty person.errors.details
end
test "copy errors" do
diff --git a/activemodel/test/cases/validations/format_validation_test.rb b/activemodel/test/cases/validations/format_validation_test.rb
index e9430cc7c4..2a7088b3e8 100644
--- a/activemodel/test/cases/validations/format_validation_test.rb
+++ b/activemodel/test/cases/validations/format_validation_test.rb
@@ -16,12 +16,12 @@ class FormatValidationTest < ActiveModel::TestCase
t = Topic.new("title" => "i'm incorrect", "content" => "Validation macros rule!")
assert t.invalid?, "Shouldn't be valid"
assert_equal ["is bad data"], t.errors[:title]
- assert_predicate t.errors[:content], :empty?
+ assert_empty t.errors[:content]
t.title = "Validation macros rule!"
assert_predicate t, :valid?
- assert_predicate t.errors[:title], :empty?
+ assert_empty t.errors[:title]
assert_raise(ArgumentError) { Topic.validates_format_of(:title, :content) }
end
@@ -42,7 +42,7 @@ class FormatValidationTest < ActiveModel::TestCase
assert t.invalid?, "Shouldn't be valid"
assert_equal ["is bad data"], t.errors[:title]
- assert_predicate t.errors[:content], :empty?
+ assert_empty t.errors[:content]
t.title = "-11"
assert t.invalid?, "Shouldn't be valid"
@@ -59,7 +59,7 @@ class FormatValidationTest < ActiveModel::TestCase
t.title = "1"
assert_predicate t, :valid?
- assert_predicate t.errors[:title], :empty?
+ assert_empty t.errors[:title]
end
def test_validate_format_with_formatted_message
diff --git a/activemodel/test/cases/validations/with_validation_test.rb b/activemodel/test/cases/validations/with_validation_test.rb
index b0ebb267f0..8239792c79 100644
--- a/activemodel/test/cases/validations/with_validation_test.rb
+++ b/activemodel/test/cases/validations/with_validation_test.rb
@@ -114,7 +114,7 @@ class ValidatesWithTest < ActiveModel::TestCase
Topic.validates_with(ValidatorPerEachAttribute, attributes: [:title, :content], allow_nil: true)
topic = Topic.new content: ""
assert_predicate topic, :invalid?
- assert_predicate topic.errors[:title], :empty?
+ assert_empty topic.errors[:title]
assert_equal ["Value is "], topic.errors[:content]
end
@@ -122,8 +122,8 @@ class ValidatesWithTest < ActiveModel::TestCase
Topic.validates_with(ValidatorPerEachAttribute, attributes: [:title, :content], allow_blank: true)
topic = Topic.new content: ""
assert_predicate topic, :valid?
- assert_predicate topic.errors[:title], :empty?
- assert_predicate topic.errors[:content], :empty?
+ assert_empty topic.errors[:title]
+ assert_empty topic.errors[:content]
end
test "validates_with can validate with an instance method" do
@@ -131,7 +131,7 @@ class ValidatesWithTest < ActiveModel::TestCase
topic = Topic.new title: "foo"
assert_predicate topic, :valid?
- assert_predicate topic.errors[:title], :empty?
+ assert_empty topic.errors[:title]
topic = Topic.new
assert_not_predicate topic, :valid?
@@ -143,7 +143,7 @@ class ValidatesWithTest < ActiveModel::TestCase
topic = Topic.new title: "foo"
assert_not_predicate topic, :valid?
- assert_predicate topic.errors[:title], :empty?
+ assert_empty topic.errors[:title]
assert_equal ["is missing"], topic.errors[:content]
end
end
diff --git a/activemodel/test/cases/validations_test.rb b/activemodel/test/cases/validations_test.rb
index 1cf1122618..7776233db5 100644
--- a/activemodel/test/cases/validations_test.rb
+++ b/activemodel/test/cases/validations_test.rb
@@ -111,8 +111,8 @@ class ValidationsTest < ActiveModel::TestCase
def test_errors_empty_after_errors_on_check
t = Topic.new
- assert_predicate t.errors[:id], :empty?
- assert_predicate t.errors, :empty?
+ assert_empty t.errors[:id]
+ assert_empty t.errors
end
def test_validates_each