Sha256: 74ed299ad7fa9bdc67ca4a2740a974c5d8e4122e469c3c7b4c5e63f38bf11de9

Contents?: true

Size: 1.6 KB

Versions: 8

Compression:

Stored size: 1.6 KB

Contents

require 'spec_helper'
require 'spec/samples/models/hydrangea_article'

include ActiveFedora::Model
include Mocha::API

describe ActiveFedora::Model do
  
  
  before(:each) do 
    module ModelIntegrationSpec
      
      class Base < ActiveFedora::Base
        include ActiveFedora::Model
        def self.pid_namespace
          "foo"
        end
      end
      class Basic < Base
      end
    end

    @test_instance = ModelIntegrationSpec::Basic.new
    @test_instance.save
    
  end
  
  after(:each) do
    @test_instance.delete
    Object.send(:remove_const, :ModelIntegrationSpec)
  end
  
  describe '#find' do
    describe "with :all" do
      it "should return an array of instances of the calling Class" do
        result = ModelIntegrationSpec::Basic.find(:all)
        result.should be_instance_of(Array)
        # this test is meaningless if the array length is zero
        result.length.should > 0
        result.each do |obj|
          obj.class.should == ModelIntegrationSpec::Basic
        end
      end
    end
    describe "#find with a valid pid" do
      subject { ActiveFedora::Base.find('hydrangea:fixture_mods_article1') }
      it { should be_instance_of HydrangeaArticle}
    end
  end

  
  describe '#load_instance' do
    it "should return an object of the given Model whose inner object is nil" do
      ActiveSupport::Deprecation.expects(:warn).with("load_instance is deprecated.  Use find instead")
      result = ModelIntegrationSpec::Basic.load_instance(@test_instance.pid)
      result.class.should == ModelIntegrationSpec::Basic
      result.inner_object.new?.should be_false
    end
  end
  
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
active-fedora-4.0.0.rc9 spec/integration/model_spec.rb
active-fedora-4.0.0.rc8 spec/integration/model_spec.rb
active-fedora-4.0.0.rc7 spec/integration/model_spec.rb
active-fedora-4.0.0.rc6 spec/integration/model_spec.rb
active-fedora-4.0.0.rc5 spec/integration/model_spec.rb
active-fedora-4.0.0.rc4 spec/integration/model_spec.rb
active-fedora-4.0.0.rc3 spec/integration/model_spec.rb
active-fedora-4.0.0.rc2 spec/integration/model_spec.rb