Writing specs for complex validations is annoying. AcceptValuesFor makes it easy to test your validations with real world values, asserting which values should be accepted by your model and which should not.
Read the original blog post.
describe User do
describe "validation" do
subject(:user) { User.new }
it { should accept_values_for(:email, "[email protected]", "[email protected]") }
it { should_not accept_values_for(:email, nil, " ", "john", "john@example") }
end
end
- Active Model (6, 7)
- RSpec (3)
group :test do
gem "accept_values_for"
end
Like AcceptValuesFor?