require 'spec_helper' describe Lva, :type=>:model do pending "add some examples to (or delete) #{__FILE__}" let_studium_lva it "should be valid" do expect(lva).to be_valid end it "should respond to semesters" do expect(lva.respond_to?(:semester)).to be true end it "should be give empty string for typ_n if typ is andere" do lva.typ="andere" expect(lva.typ_n).to eq("") end it "should have title as an alias for name" do lva.name="sdfWER" expect(lva.title).to eq("sdfWER") end it "should have a full name containing typ and name" do lva.typ="VO" expect(lva.full_name).to match "VO" expect(lva.full_name).to match lva.name end it "should have a semester after fixing" do expect(lva.semester).to be_empty studium.semester << zerosemester studium.save expect(studium.semester).not_to be_empty lva.add_semesters expect(lva.semester).not_to be_empty end it "can create a valid tiss link" do lva.lvanr="101.679" tl=lva.tisslink expect(tl).to match "101679" expect(tl).to match "tiss.tuwien.ac.at" end it "should be able to load tissdata" do lva.lvanr="101.679" n=lva.name expect(lva.name).to eq(n) lva.load_tissdata expect(lva.name).not_to eq(n) end describe "if bare" do let(:lva) {FactoryGirl.build(:lva)} it "should be created" do l=lva l.modul << modul expect{l.save!; Sunspot.commit}.to change{Lva.count}.by(1) end it "should not be valid without module" do l=lva expect(l.valid?).to be false expect(l.errors[:modul].size).to be(1) end end pending "should not be valid if it doesn't have a Semester for a studium" pending "should not be valid without modul" pending "should have beispiele" pending "should be flagable" end