AutoCommit Son Aug 30 14:03:01 CEST 2015

This commit is contained in:
Andreas Stephanides
2015-08-30 14:03:01 +02:00
parent 723d7be980
commit 5bf63421a6
9 changed files with 64 additions and 6 deletions

View File

@@ -1,5 +1,20 @@
require 'spec_helper'
describe Beispiel do
pending "add some examples to (or delete) #{__FILE__}"
it "should be created" do
b=FactoryGirl.build(:beispiel)
l=FactoryGirl.create(:lva)
b.lva=l
expect{b.save!; Sunspot.commit}.to change{Beispiel.count}.by(1)
end
it "should not be valid without lva" do
b=FactoryGirl.build(:beispiel)
expect(b.valid?).to be false
end
it "shout respond to comments" do
b=FactoryGirl.create(:beispiel)
expect(b.responds_to?(:comments)).to be true
end
pending "should be flagable"
end

View File

@@ -2,4 +2,26 @@ require 'spec_helper'
describe Lva do
pending "add some examples to (or delete) #{__FILE__}"
it "should be created" do
l=FactoryGirl.build(:lva)
mg=FactoryGirl.build(:modulgruppe)
s=FactoryGirl.create(:studium)
mg.studium= s
mg.save!
m=FactoryGirl.build(:other_modul)
m.modulgruppe=mg
m.save!
l.modul= m
expect{l.save!; Sunspot.commit}.to change{Lva.count}.by(1)
end
it "should not be valid without module" do
l=FactoryGirl.build(:lva)
expect(l.valid?).to be false
expect(l.errors[:modul].size).to be(1)
end
pending "should not be valid without modul"
pending "should have beispiele"
pending "should be flagable"
end

View File

@@ -1,6 +1,7 @@
require 'spec_helper'
describe Studium do
# test if it is invalid if certain attributes are missing
[:name, :zahl].each do |attr|
it "should not be valid without #{attr}" do
s = FactoryGirl.build(:studium, attr=>nil)
@@ -10,18 +11,20 @@ describe Studium do
it "should create studium with valid data" do
s=FactoryGirl.build(:studium)
lambda {
s.save!}.should change {Studium.count()}.by(1)
s.save!; Sunspot.commit}.should change {Studium.count()}.by(1)
end
it "should not accept double entrys" do
FactoryGirl.create(:studium)
Sunspot.commit
s=FactoryGirl.build(:studium)
s.should_not be_valid
s.should have_at_least(1).error_on(:name)
s.should have_at_least(1).error_on(:zahl)
end
it "should expect zahl to be 000.000" do
s=FactoryGirl.build(:studium, :zahl=>"000000")
s=FactoryGirl.build(:studium, :zahl=>"000.000")
Sunspot.commit
s.should_not be_valid
s.should have_at_least(1).error_on(:zahl)
expect(s.errors.size).to be > 0
end
end