Sha256: 3715ff0cb762193a8c996a001d2ce60a25c1d3e0108fc03b4c78757bdc01539d

Contents?: true

Size: 1.75 KB

Versions: 7

Compression:

Stored size: 1.75 KB

Contents

require "spec_helper"
describe ActiveTriples::Configurable do
  before do
    class DummyConfigurable
      extend ActiveTriples::Configurable
    end
  end
  after do
    Object.send(:remove_const, "DummyConfigurable")
  end

  it "should be okay if not configured" do
    expect(DummyConfigurable.type).to eq nil
  end
  it "should be okay if configured to nil" do
    DummyConfigurable.configure :type => nil
    expect(DummyConfigurable.type).to eq []
  end
  describe '#configure' do
    before do
      DummyConfigurable.configure base_uri: "http://example.org/base", type: RDF::RDFS.Class, rdf_label: RDF::DC.title
    end

    it 'should set a base uri' do
      expect(DummyConfigurable.base_uri).to eq "http://example.org/base"
    end

    it "should be able to set multiple types" do
      DummyConfigurable.configure type: [RDF::RDFS.Container, RDF::RDFS.ContainerMembershipProperty]
      expect(DummyConfigurable.type).to contain_exactly(RDF::RDFS.Class, RDF::RDFS.Container, RDF::RDFS.ContainerMembershipProperty)
    end

    it 'should set an rdf_label' do
      expect(DummyConfigurable.rdf_label).to eq RDF::DC.title
    end

    it 'should set a type' do
      expect(DummyConfigurable.type).to eq [RDF::RDFS.Class]
    end
    it "should be able to set multiple types" do
      DummyConfigurable.configure type: RDF::RDFS.Container
      expect(DummyConfigurable.type).to eq [RDF::RDFS.Class, RDF::RDFS.Container]
    end
  end

  describe '#rdf_type' do
    it "should set the type the old way" do
      expect(DummyConfigurable).to receive(:configure).with(type: RDF::RDFS.Class).and_call_original
      expect(Deprecation).to receive(:warn)
      DummyConfigurable.rdf_type(RDF::RDFS.Class)
      expect(DummyConfigurable.type).to eq [RDF::RDFS.Class]
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
active-triples-0.7.6 spec/active_triples/configurable_spec.rb
active-triples-0.7.5 spec/active_triples/configurable_spec.rb
active-triples-0.7.4 spec/active_triples/configurable_spec.rb
active-triples-0.7.3 spec/active_triples/configurable_spec.rb
active-triples-0.7.2 spec/active_triples/configurable_spec.rb
active-triples-0.7.1 spec/active_triples/configurable_spec.rb
active-triples-0.7.0 spec/active_triples/configurable_spec.rb