Sha256: 8ed6ac4420d03c2e93c44d8a9bef898237cb66d33c38960ff651649114383f0b
Contents?: true
Size: 1.03 KB
Versions: 55
Compression:
Stored size: 1.03 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 delegate :fubar, :to=>'someData' delegate :swank, :to=>'someData' validates_presence_of :fubar validates_length_of :swank, :minimum=>5 end end after :all do Object.send(:remove_const, :ValidationStub) end describe "a valid object" do before do @obj = ValidationStub.new(:fubar=>'here', :swank=>'long enough') end it "should be valid" do @obj.should_not be_valid end end describe "an invalid object" do before do @obj = ValidationStub.new(:swank=>'smal') end it "should be invalid" do @obj.should_not be_valid @obj.errors[:fubar].should == ["can't be blank"] @obj.errors[:swank].should == ["is too short (minimum is 5 characters)"] end end end
Version data entries
55 entries across 55 versions & 1 rubygems