require 'spec_helper' describe Modulgruppe, :type =>:model do it "should not be valid without studium" do mg=FactoryBot.build(:modulgruppe) mg.should_not be_valid mg.should have(1).errors_on(:studium_id) end it "should be valid with studium" do s=FactoryBot.create(:studium) mg=FactoryBot.build(:modulgruppe) mg.studium=s mg.should be_valid end it "should not be valid without name" do s=FactoryBot.create(:studium) mg=FactoryBot.build(:modulgruppe) mg.studium=s mg.name=nil mg.should_not be_valid mg.should have_at_least(1).errors_on(:name) end xit "should not be valid with dubble name" do s=FactoryBot.create(:studium) mg=FactoryBot.build(:modulgruppe, name: "Gruppe 1", desc: "132") mg.studium=s mg.save mg=FactoryBot.build(:modulgruppe, name: "Gruppe 2", desc: "133") mg.studium=s mg.should_not be_valid mg.should have_at_least(1).errors_on(:name) end it "should be valid with same name on different studien" do s=FactoryBot.create(:studium) s2=FactoryBot.create(:other_studium) mg=FactoryBot.build(:modulgruppe, name: "Gruppe") mg.studium=s mg.save mg=FactoryBot.build(:other_modulgruppe, name: "Gruppe") mg.studium=s2 mg.should be_valid end pending "add some examples to (or delete) #{__FILE__}" pending "DRY #{__FILE__}" end