1

I have custom validations in rails model:

validate :custom_validation_method

def custom_validation_method
  # do stuff here
end

How can I make RSpec for this? Thanks!

1 Answer 1

3

To test validations(any)

describe MyClass do
  it '#custom_validation' do
    expect(subject.valid?).to be_falsey
    #do stuff to subject to make it valid
    expect(subject.valid?).to be_truthy
  end
end
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.