Sha256: 409b6d3fab845dc930d8c6aaa6d3e3e104e12d5010732af13e2481865ecb24c1

Contents?: true

Size: 1.66 KB

Versions: 5

Compression:

Stored size: 1.66 KB

Contents

require File.join(File.dirname(__FILE__), 'spec_helper')
describe "Blank nodes" do
  before(:all) { @context = {} }
  
  describe "which have custom identifiers" do
    subject { BNode.new("foo", @context) }
  
    it "should return identifier" do
      subject.identifier.should =~ /foo/
      subject.to_s.should =~ /foo/
    end

    it "should be rejected if they are not acceptable" do
      b = BNode.new("4cake", @context)
      b.identifier.should_not =~ /4cake/
    end

    it "should be expressible in NT syntax" do
      subject.to_ntriples.should =~ /foo/
    end

    it "should be able to determine equality" do
      other = BNode.new(subject.to_s, @context)
      should == other
    end

    it "should be able to determine inequality" do
      other = URIRef.new('http://somehost.com/wherever.xml')
      should_not == other
    end

    it "should resource hash for RDF/XML named bnode" do
      subject.xml_args.should == [{"rdf:nodeID" => subject.to_s}]
    end
  end

  describe "which has a blank identifier" do
    subject { BNode.new("", @context) }
    it "should not be the same as an anonymous identifier" do should_not == BNode.new end
    it "should be the same as another blank identifier" do should == BNode.new("", @context) end
  end

  describe "which are anonymous" do
    subject { BNode.new(@graph)}
    it "should not be equivalent to another anonymous node" do
      should_not == BNode.new
    end
    
    it "should be equivalent it's clone" do
      should == subject.clone
    end
    
    it "should create resource hash for RDF/XML anonymous bnode" do
      b = BNode.new
      b.xml_args.should == [{"rdf:nodeID" => b.identifier}]
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
rdf_context-0.4.5 spec/bnode_spec.rb
rdf_context-0.4.4 spec/bnode_spec.rb
rdf_context-0.4.3 spec/bnode_spec.rb
rdf_context-0.4.2 spec/bnode_spec.rb
gkellogg-reddy-0.2.1 spec/bnode_spec.rb