Skip to content

Commit

Permalink
Fix certain tests not assert correct values for Rails 2.2+
Browse files Browse the repository at this point in the history
Assert invalid attributes using invalid? rather than checking exactly how many errors there are
  • Loading branch information
obrie committed Dec 5, 2008
1 parent 36fcc71 commit 7c34b49
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions test/unit/preference_definition_test.rb
Expand Up @@ -95,8 +95,8 @@ def test_should_type_cast_to_true_if_value_is_true_string
assert_equal true, @definition.type_cast('true')
end

def test_should_type_cast_to_false_if_value_is_not_true_string
assert_equal false, @definition.type_cast('')
def test_should_type_cast_to_nil_if_value_is_not_true_string
assert_nil @definition.type_cast('')
end

def test_should_query_false_if_value_is_nil
Expand Down
8 changes: 4 additions & 4 deletions test/unit/preference_test.rb
Expand Up @@ -43,19 +43,19 @@ def test_should_be_valid_with_a_set_of_valid_attributes
def test_should_require_an_attribute
preference = new_preference(:attribute => nil)
assert !preference.valid?
assert_equal 1, Array(preference.errors.on(:attribute)).size
assert preference.errors.invalid?(:attribute)
end

def test_should_require_an_owner_id
preference = new_preference(:owner => nil)
assert !preference.valid?
assert_equal 1, Array(preference.errors.on(:owner_id)).size
assert preference.errors.invalid?(:owner_id)
end

def test_should_require_an_owner_type
preference = new_preference(:owner => nil)
assert !preference.valid?
assert_equal 1, Array(preference.errors.on(:owner_type)).size
assert preference.errors.invalid?(:owner_type)
end

def test_should_not_require_a_group_id
Expand All @@ -78,7 +78,7 @@ def test_should_require_a_group_type_if_id_specified
preference = new_preference(:group => nil)
preference.group_id = 1
assert !preference.valid?
assert_equal 1, Array(preference.errors.on(:group_type)).size
assert preference.errors.invalid?(:group_type)
end

def test_should_protect_attributes_from_mass_assignment
Expand Down

0 comments on commit 7c34b49

Please sign in to comment.