Sha256: 2a5ddb9cb8d6bc9b7800016d6dc3e38c2dd20f73c8de5be0e4e86eb964792270

Contents?: true

Size: 1.14 KB

Versions: 5

Compression:

Stored size: 1.14 KB

Contents

# frozen_string_literal: true
require 'spec_helper'

RSpec.describe ActiveTriples::ExtensionStrategy do
  subject { described_class }

  describe ".apply" do
    it "should copy the property to the asset" do
      asset = build_asset
      property = build_property("name", {:predicate => RDF::Vocab::DC.title})

      subject.apply(asset, property)

      expect(asset).to have_received(:property).with(property.name, property.to_h)
    end

    it 'execute the block' do
      block = Proc.new {}
      asset = build_asset
      property = build_property("name", {:predicate => RDF::Vocab::DC.title}, &block)

      subject.apply(asset, property)

      expect(asset).to have_received(:property).with(property.name, property.to_h, &block)
    end

    def build_asset
      object_double(ActiveTriples::Resource, :property => nil)
    end

    def build_property(name, options, &block)
      property = object_double(ActiveTriples::Property.new(:name => nil))
      allow(property).to receive(:name).and_return(name)
      allow(property).to receive(:to_h).and_return(options)
      allow(property).to receive(:config).and_return(block)
      property
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
active-triples-1.2.0 spec/active_triples/extension_strategy_spec.rb
active-triples-1.1.1 spec/active_triples/extension_strategy_spec.rb
active-triples-1.1.0 spec/active_triples/extension_strategy_spec.rb
active-triples-1.0.0 spec/active_triples/extension_strategy_spec.rb
active-triples-1.0.0.rc1 spec/active_triples/extension_strategy_spec.rb