Model

Need install shoulda-machers gem first, follow the instructions on http:\/\/www.rubydoc.info\/gems\/shoulda

Testing asssociations of models
describe AnyModel, :type => :model do
  describe 'relation' do
    it { should belong_to(:model) }
    it { should have_many(:models) }
  end
end

Testing validations

it do
  subject.any_attribute = 'XX'
  expect(subject.valid?).to be_falsey
  expect(subject.errors.keys).to include :any_attribute
end

Reference

results matching ""

    No results matching ""