Sha256: dc828b0389d688ad5e7bd586ce323029f3d5145638abc2af964b71f869704d67
Contents?: true
Size: 1.28 KB
Versions: 8
Compression:
Stored size: 1.28 KB
Contents
require 'spec_helper' describe ActiveFedora::Base do before :all do class ValidationStub < ActiveFedora::Base has_metadata :type=>ActiveFedora::SimpleDatastream, :name=>"someData" do |m| m.field "fubar", :string m.field "swank", :text end has_attributes :fubar, datastream: 'someData', multiple: true has_attributes :swank, datastream: 'someData', multiple: false validates_presence_of :fubar validates_length_of :swank, :minimum=>5 end end subject { ValidationStub.new } after :all do Object.send(:remove_const, :ValidationStub) end describe "a valid object" do before do subject.attributes = { fubar: ['here'], swank: 'long enough' } end it { is_expected.to be_valid} end describe "an invalid object" do before do subject.attributes = { swank: 'smal' } end it "should have errors" do expect(subject).not_to be_valid expect(subject.errors[:fubar]).to eq(["can't be blank"]) expect(subject.errors[:swank]).to eq(["is too short (minimum is 5 characters)"]) end end describe "required terms" do it "should be required" do expect(subject.required?(:fubar)).to be true expect(subject.required?(:swank)).to be false end end end
Version data entries
8 entries across 8 versions & 1 rubygems