I have a model that looks something like this:
class User
include Mongoid::Document
field :email
validate :email, presence: true, uniqueness: true
end
And I have a test that looks like...
it { User.new.should_not be_valid }
it { FactoryGirl.build(:user).should be_valid }
it { should validate_presence_of :email }
it { should validate_uniqueness_of :email }
Both of these want to hit the database when the .valid?
method is called. Is there someway I can abstract that out? The uniqueness validator has been tested thoroughly by plenty of other folks, so the last line above is good enough for me.
Not that big a deal if I must run a DB during model specs, but I'd rather avoid it if possible.