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

Version Path
active-fedora-5.7.1 spec/unit/validations_spec.rb
active-fedora-5.7.0 spec/unit/validations_spec.rb
active-fedora-6.2.0 spec/unit/validations_spec.rb
active-fedora-6.1.1 spec/unit/validations_spec.rb
active-fedora-6.1.0 spec/unit/validations_spec.rb
active-fedora-5.6.3 spec/unit/validations_spec.rb
active-fedora-6.0.0 spec/unit/validations_spec.rb
active-fedora-6.0.0.rc7 spec/unit/validations_spec.rb
active-fedora-6.0.0.rc6 spec/unit/validations_spec.rb
active-fedora-6.0.0.rc5 spec/unit/validations_spec.rb
active-fedora-6.0.0.rc4 spec/unit/validations_spec.rb
active-fedora-6.0.0.rc3 spec/unit/validations_spec.rb
active-fedora-6.0.0.rc2 spec/unit/validations_spec.rb
active-fedora-6.0.0.rc1 spec/unit/validations_spec.rb
active-fedora-5.6.2 spec/unit/validations_spec.rb
active-fedora-5.6.1 spec/unit/validations_spec.rb
active-fedora-6.0.0.pre10 spec/unit/validations_spec.rb
active-fedora-6.0.0.pre9 spec/unit/validations_spec.rb
active-fedora-5.6.0 spec/unit/validations_spec.rb
active-fedora-6.0.0.pre8 spec/unit/validations_spec.rb