require 'spec_helper' describe Modul do [:name].each do |attr| it "should not be valid without #{attr}" do modul = FactoryBot.build(:modul) modul.send("#{attr}=".to_sym,nil) expect(modul).not_to be_valid expect(modul).to have_at_least(1).errors_on(attr) end end it "is valid with everything" do m = FactoryBot.build(:modul) expect(m).to be_valid end end