Update variable's name in the test case to reflect the class we're testing

This commit is contained in:
Prem Sichanugrist
2011-11-18 11:51:05 -05:00
parent d4119e144a
commit 0e2156d334
3 changed files with 24 additions and 24 deletions

View File

@@ -46,12 +46,12 @@ class ExclusionValidationTest < ActiveModel::TestCase
def test_validates_exclusion_of_with_lambda
Topic.validates_exclusion_of :title, :in => lambda{ |topic| topic.author_name == "sikachu" ? %w( monkey elephant ) : %w( abe wasabi ) }
p = Topic.new
p.title = "elephant"
p.author_name = "sikachu"
assert p.invalid?
t = Topic.new
t.title = "elephant"
t.author_name = "sikachu"
assert t.invalid?
p.title = "wasabi"
assert p.valid?
t.title = "wasabi"
assert t.valid?
end
end

View File

@@ -101,25 +101,25 @@ class PresenceValidationTest < ActiveModel::TestCase
def test_validates_format_of_with_lambda
Topic.validates_format_of :content, :with => lambda{ |topic| topic.title == "digit" ? /\A\d+\Z/ : /\A\S+\Z/ }
p = Topic.new
p.title = "digit"
p.content = "Pixies"
assert p.invalid?
t = Topic.new
t.title = "digit"
t.content = "Pixies"
assert t.invalid?
p.content = "1234"
assert p.valid?
t.content = "1234"
assert t.valid?
end
def test_validates_format_of_without_lambda
Topic.validates_format_of :content, :without => lambda{ |topic| topic.title == "characters" ? /\A\d+\Z/ : /\A\S+\Z/ }
p = Topic.new
p.title = "characters"
p.content = "1234"
assert p.invalid?
t = Topic.new
t.title = "characters"
t.content = "1234"
assert t.invalid?
p.content = "Pixies"
assert p.valid?
t.content = "Pixies"
assert t.valid?
end
def test_validates_format_of_for_ruby_class

View File

@@ -78,12 +78,12 @@ class InclusionValidationTest < ActiveModel::TestCase
def test_validates_inclusion_of_with_lambda
Topic.validates_inclusion_of :title, :in => lambda{ |topic| topic.author_name == "sikachu" ? %w( monkey elephant ) : %w( abe wasabi ) }
p = Topic.new
p.title = "wasabi"
p.author_name = "sikachu"
assert p.invalid?
t = Topic.new
t.title = "wasabi"
t.author_name = "sikachu"
assert t.invalid?
p.title = "elephant"
assert p.valid?
t.title = "elephant"
assert t.valid?
end
end