Sha256: 4a4456604efaff3807c631d390b8c9d70e67b5975975d53d6add9977859730ea

Contents?: true

Size: 1.15 KB

Versions: 6

Compression:

Stored size: 1.15 KB

Contents

require 'spec_helper'

describe ActiveFedora::DefaultModelMapper do
  let(:classifier) { double }
  let(:classifier_instance) { double }
  let(:solr_field) { 'solr_field' }
  let(:predicate) { 'info:predicate' }
  subject(:mapper) { described_class.new classifier_class: classifier, solr_field: solr_field, predicate: predicate }

  describe '#classifier' do
    context 'with a solr document' do
      let(:solr_document) { { 'solr_field' => ['xyz'] } }

      before do
        expect(classifier).to receive(:new).with(['xyz']).and_return(classifier_instance)
      end

      it 'creates a classifier from the solr field data' do
        expect(mapper.classifier(solr_document)).to eq classifier_instance
      end
    end

    context 'with a resource' do
      let(:graph) do
        RDF::Graph.new << [:hello, predicate, 'xyz']
      end

      let(:resource) { double(graph: graph) }

      before do
        expect(classifier).to receive(:new).with(['xyz']).and_return(classifier_instance)
      end

      it 'creates a classifier from the resource model predicate' do
        expect(mapper.classifier(resource)).to eq classifier_instance
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
active-fedora-11.0.0.rc7 spec/unit/default_model_mapper_spec.rb
active-fedora-11.0.0.rc6 spec/unit/default_model_mapper_spec.rb
active-fedora-11.0.0.rc5 spec/unit/default_model_mapper_spec.rb
active-fedora-11.0.0.rc4 spec/unit/default_model_mapper_spec.rb
active-fedora-11.0.0.rc3 spec/unit/default_model_mapper_spec.rb
active-fedora-11.0.0.rc2 spec/unit/default_model_mapper_spec.rb