Sha256: 7422541b3b8ed83708f7e996f7bf20c11e189434dacc7270dbbe81c087a96b9d

Contents?: true

Size: 1.02 KB

Versions: 3

Compression:

Stored size: 1.02 KB

Contents

require 'spec_helper'

describe FedoraMigrate::DatesMover do
  let(:target) { ExampleModel::RDFObject.new }
  let(:source) { instance_double('Source', createdDate: 'yesterday', lastModifiedDate: 'today') }

  subject { FedoraMigrate::DatesMover.new(source, target) }

  describe '#migrate' do

    it 'migrates the create and mod dates' do
      subject.migrate
      expect(target.date_uploaded).to eq 'yesterday'
      expect(target.date_modified).to eq 'today'
    end

    context "when the source methods don't exist" do
      let(:source) { instance_double('Source with no date methods') }
      it 'gracefully does nothing' do
        expect{ subject.migrate }.to_not raise_error
        expect(target.date_uploaded).to be_nil
        expect(target.date_modified).to be_nil
      end
    end

    context "when the target methods don't exist" do
      let(:target) { instance_double('Target with no date methods') }
      it 'gracefully does nothing' do
        expect{ subject.migrate }.to_not raise_error
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fedora-migrate-0.3.0 spec/unit/dates_mover_spec.rb
fedora-migrate-0.2.0 spec/unit/dates_mover_spec.rb
fedora-migrate-0.1.0 spec/unit/dates_mover_spec.rb