I'm having trouble with the following attributes within my class. I have a date attribute with presence true that is enforced at database level too:
validates :date, presence: true
In addition to that, I need to enforce combined uniqueness for the following two attributes
validates :name, uniqueness: { scope: :parent_id }
So far... everything is ok, but I want to have a spec testing the uniqueness
it { should validate_uniqueness_of(:name).scoped_to(:parent_id) }
But the problem with line above is that it will try to insert a record on db by just using a random name and parent_id values letting the date one to be nil. Thus, it fails on database.
I already tried doing subject { build(:my_model) }
on the test, however the it line is still creating it's own one and not setting the date attribute.
How can I make shoulda to use the subject I created? I am missing something?