Sha256: 947c4f8520c7300b4f277fe8db5880e7ac0c9c52416cc9ec8cd5039606872138

Contents?: true

Size: 1.57 KB

Versions: 8

Compression:

Stored size: 1.57 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/spec_helper')

describe "Neo4j Working Examples" do
  it "queries all nodes" do
    Neo4jr::DB.execute do |neo|
      hanks = neo.all_nodes.select{|people| people if people.get_property('name').match(/Hanks/) rescue nil }
      hanks.should have(2).nodes
      hanks.first.get_property('name').should == 'Hanks, Tom'
      hanks.last.get_property('name').should == 'Hanks, Jay (I)'
    end
  end
  
  it 'cruds nodes' do
    node_id = nil
    #CREATES
    Neo4jr::DB.execute do |neo|
      node = neo.createNode
      node[:name] = 'Deiters, Matt'
      node_id = node.getId
    end

    #UPDATES
    node = Neo4jr::DB.getNodeById(node_id)
    node[:name].should == 'Deiters, Matt'

    #DELETES
    Neo4jr::DB.execute do |neo|
      node = neo.getNodeById(node_id)
      node.delete
    end
  end
  
  it 'can traverse a node using the raw API' do
    Neo4jr::DB.execute do |neo|
      # Node[1102]: Hoffman, Philip Seymour
      # Node[1104]: Hoffman, Dustin    
      philip_seymour_hoffman = neo.getNodeById(1102)

      order        = Neo4jr::Order::BREADTH_FIRST
      stop_when    = Neo4jr::StopEvaluator::END_OF_GRAPH
      return_when  = Neo4jr::ReturnableEvaluator::ALL
      relationship = Neo4jr::RelationshipType.outgoing(:acted_in)
      
      traverser = philip_seymour_hoffman.traverse(order, stop_when, return_when, relationship)
      # traverser.each do |person_or_movie|
      #   puts person_or_movie.get_property('title') rescue person_or_movie.get_property('name')
      # end
      traverser.size.should == 15
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
neo4jr-simple-0.2.2 spec/functional_example_spec.rb
neo4jr-simple-0.2.1 spec/functional_example_spec.rb
neo4jr-simple-0.2.0 spec/functional_example_spec.rb
neo4jr-simple-0.1.8 spec/functional_example_spec.rb
neo4jr-simple-0.1.7 spec/functional_example_spec.rb
neo4jr-simple-0.1.6 spec/functional_example_spec.rb
neo4jr-simple-0.1.5 spec/functional_example_spec.rb
neo4jr-simple-0.1.3 spec/functional_example_spec.rb