module Ubazu::Rspec::Matchers::ActiveRecord
Matchers
for your active record models¶ ↑
These matchers will test most of the validations and associations for your ActiveRecord
models.
describe User do it { should validate_presence_of(:name) } it { should validate_presence_of(:phone_number) } %w(abcd 1234).each do |value| it { should_not allow_value(value).for(:phone_number) } end it { should allow_value("(123) 456-7890").for(:phone_number) } it { should_not allow_mass_assignment_of(:password) } it { should have_one(:profile) } it { should have_many(:dogs) } it { should have_many(:messes).through(:dogs) } it { should belong_to(:lover) } end