Sha256: 97cc929845027bfccb160c5512834a4d91885da8bda1806d1c1f3678b15e9ae2

Contents?: true

Size: 1.79 KB

Versions: 1

Compression:

Stored size: 1.79 KB

Contents

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

describe PubliSci::Prov::Activity do

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

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

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

  it "can be created with a block" do
    e = entity :data
    a = activity :ag do
      subject "http://things.com/stuff"
      generated :data
    end
    a.is_a?(Activity).should be true
    a.subject.should == "http://things.com/stuff"
  end

  it "lazy loads other objects" do
    a = activity :ag do
      subject "http://things.com/stuff"
      generated :data
    end
    e = entity :data

    a.generated[0].should == e
  end

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

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

  it "lazy loads generated relationships" do
    a = activity :act, generated: :data
    e = entity :data

    a.generated[0].should == e
  end

  it "lazy loads used relationships" do
    a = activity :act, generated: :data, used: :other_data
    e = entity :data
    f = entity :other_data

    a.used[0].should == f
  end

  # it "lazy loads other objects, so declaration order doesn't usually matter" do
  #   a = activity :name, on_behalf_of: :other
  #   b = activity :other

  #   a.on_behalf_of.should == b
  # end

end

Version data entries

1 entries across 1 versions & 1 rubygems

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