Files
fetsite/spec/models/studium_spec.rb
2015-08-30 14:03:01 +02:00

31 lines
840 B
Ruby

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)
s.should_not be_valid
end
end
it "should create studium with valid data" do
s=FactoryGirl.build(:studium)
lambda {
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=>"000.000")
Sunspot.commit
s.should_not be_valid
expect(s.errors.size).to be > 0
end
end