Sha256: 088d8b0be3495cdeb56e36007217a84d79a1dbc6b69d5f2d131a4e6df6da2434

Contents?: true

Size: 1.47 KB

Versions: 1

Compression:

Stored size: 1.47 KB

Contents

require_relative '../../lib/bio-publisci.rb'
include PubliSci::Prov::DSL
include PubliSci::Prov

describe PubliSci::Prov::Entity do
  before(:each) do
    @evaluator = PubliSci::Prov::DSL::Singleton.new
  end

  it "can generate entity fields from symbol" do
    e = entity :name
    e.is_a?(Entity).should be true
    e.subject.should == "http://rqtl.org/ns/entity/name"
  end

  it "can specify fields manually" do
    e = entity :name, subject: "http://example.org/name"
    e.subject.should == "http://example.org/name"
  end

  it "can be created with a block" do
    e = entity :ent do
      subject "http://things.com/stuff"
      source "/somefile.txt"
    end
    e.is_a?(Entity).should be true
    e.subject.should == "http://things.com/stuff"
    e.source[0].should == "/somefile.txt"
  end

  it "raises an exception when derivation does not refer to an entity" do
    e = entity :name, derived_from: :dataset
    expect {e.derived_from[0]}.to raise_error
  end

  it "raises an exception when attribution does not refer to an agent" do
    e = entity :name, attributed_to: :person
    expect {e.attributed_to[0]}.to raise_error
  end

  it "raises an exception when generated_by does not refer to an activity" do
    e = entity :name, generated_by: :act
    expect {e.generated_by[0]}.to raise_error
  end

  it "lazy loads other objects, so declaration order doesn't usually matter" do
    e = entity :name, derived_from: :other
    f = entity :other


    e.derived_from[0].should == f
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bio-publisci-0.0.6 spec/prov/entity_spec.rb