Skip to content

Commit

Permalink
Added test case as raising ArgumentError
Browse files Browse the repository at this point in the history
  • Loading branch information
kouyaf77 committed Nov 28, 2016
1 parent 05d71c9 commit 586c702
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test/active_model/cases/test_validations.rb
Expand Up @@ -328,6 +328,16 @@ def test_conditional_lambda_validators
assert_equal expected_hash, person.client_side_validation_hash(true)
end

def test_conditional_lambda_with_2_arguments_validators
person = new_person do |p|
p.validates :first_name, presence: { if: ->(_a, _b) { can_validate? } }
end

person.stubs(:can_validate?).returns true

assert_raises(ArgumentError) { person.client_side_validation_hash(true) }
end

def test_conditional_lambda_without_argument_validators
person = new_person do |p|
p.validates :first_name, presence: { if: -> { can_validate? } }
Expand Down

0 comments on commit 586c702

Please sign in to comment.