Skip to content
This repository has been archived by the owner on Feb 17, 2023. It is now read-only.

Commit

Permalink
Test that AnySchema ignores allow_nil.
Browse files Browse the repository at this point in the history
Since it already allow it...
  • Loading branch information
nicolasdespres committed May 19, 2013
1 parent 6a8fff0 commit 5e20859
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/any_schema_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,21 @@ def test_failed_validation_reset_sanitized_object
assert_schema_invalidate(s, Object.new)
assert_equal(nil, s.sanitized_object)
end

def test_allow_nil
s = Respect::AnySchema.new(allow_nil: true)
assert_schema_validate s, nil
assert_equal(nil, s.sanitized_object)
assert_schema_validate s, 42
assert_equal(42, s.sanitized_object)
end

def test_disallow_nil
s = Respect::AnySchema.new
assert !s.allow_nil?
assert_schema_validate s, nil
assert_equal(nil, s.sanitized_object)
assert_schema_validate s, 42
assert_equal(42, s.sanitized_object)
end
end

0 comments on commit 5e20859

Please sign in to comment.