Skip to content
This repository
Browse code

use assert_empty in activemodel conditional validation test cases

  • Loading branch information...
commit 782d794c208cc7a0ac924b8f7cb3813015580d44 1 parent a1de8a8
Rajarshi Das rajcybage authored
14 activemodel/test/cases/validations/conditional_validation_test.rb
@@ -23,7 +23,7 @@ def test_unless_validation_using_method_true
23 23 Topic.validates_length_of(:title, maximum: 5, too_long: "hoo %{count}", unless: :condition_is_true)
24 24 t = Topic.new("title" => "uhohuhoh", "content" => "whatever")
25 25 assert t.valid?
26   - assert t.errors[:title].empty?
  26 + assert_empty t.errors[:title]
27 27 end
28 28
29 29 def test_if_validation_using_method_false
@@ -31,7 +31,7 @@ def test_if_validation_using_method_false
31 31 Topic.validates_length_of(:title, maximum: 5, too_long: "hoo %{count}", if: :condition_is_true_but_its_not)
32 32 t = Topic.new("title" => "uhohuhoh", "content" => "whatever")
33 33 assert t.valid?
34   - assert t.errors[:title].empty?
  34 + assert_empty t.errors[:title]
35 35 end
36 36
37 37 def test_unless_validation_using_method_false
@@ -57,7 +57,7 @@ def test_unless_validation_using_string_true
57 57 Topic.validates_length_of(:title, maximum: 5, too_long: "hoo %{count}", unless: "a = 1; a == 1")
58 58 t = Topic.new("title" => "uhohuhoh", "content" => "whatever")
59 59 assert t.valid?
60   - assert t.errors[:title].empty?
  60 + assert_empty t.errors[:title]
61 61 end
62 62
63 63 def test_if_validation_using_string_false
@@ -65,7 +65,7 @@ def test_if_validation_using_string_false
65 65 Topic.validates_length_of(:title, maximum: 5, too_long: "hoo %{count}", if: "false")
66 66 t = Topic.new("title" => "uhohuhoh", "content" => "whatever")
67 67 assert t.valid?
68   - assert t.errors[:title].empty?
  68 + assert_empty t.errors[:title]
69 69 end
70 70
71 71 def test_unless_validation_using_string_false
@@ -93,7 +93,7 @@ def test_unless_validation_using_block_true
93 93 unless: Proc.new { |r| r.content.size > 4 })
94 94 t = Topic.new("title" => "uhohuhoh", "content" => "whatever")
95 95 assert t.valid?
96   - assert t.errors[:title].empty?
  96 + assert_empty t.errors[:title]
97 97 end
98 98
99 99 def test_if_validation_using_block_false
@@ -102,7 +102,7 @@ def test_if_validation_using_block_false
102 102 if: Proc.new { |r| r.title != "uhohuhoh"})
103 103 t = Topic.new("title" => "uhohuhoh", "content" => "whatever")
104 104 assert t.valid?
105   - assert t.errors[:title].empty?
  105 + assert_empty t.errors[:title]
106 106 end
107 107
108 108 def test_unless_validation_using_block_false
@@ -124,7 +124,7 @@ def test_validation_with_if_as_string
124 124
125 125 t = Topic.new
126 126 assert t.invalid?, "A topic without a title should not be valid"
127   - assert t.errors[:author_name].empty?, "A topic without an 'important' title should not require an author"
  127 + assert_empty t.errors[:author_name], "A topic without an 'important' title should not require an author"
128 128
129 129 t.title = "Just a title"
130 130 assert t.valid?, "A topic with a basic title should be valid"

0 comments on commit 782d794

Please sign in to comment.
Something went wrong with that request. Please try again.