neography 1.1.3 → 1.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml CHANGED
@@ -1,4 +1,4 @@
1
- script: "bundle exec rake neo4j:install['enterprise','2.0.0-M03'] neo4j:start spec --trace"
1
+ script: "bundle exec rake neo4j:install['enterprise','2.0.0-M04'] neo4j:start spec --trace"
2
2
  language: ruby
3
3
  rvm:
4
4
  - 1.9.3
@@ -299,6 +299,10 @@ module Neography
299
299
  @node_indexes.find(index, key_or_query, value)
300
300
  end
301
301
 
302
+ def drop_node_index(index)
303
+ @node_indexes.drop(index)
304
+ end
305
+
302
306
  # auto node indexes
303
307
 
304
308
  def get_node_auto_index(key, value)
@@ -362,6 +366,10 @@ module Neography
362
366
  def find_relationship_index(index, key_or_query, value = nil)
363
367
  @relationship_indexes.find(index, key_or_query, value)
364
368
  end
369
+
370
+ def drop_relationship_index(index)
371
+ @relationship_indexes.drop(index)
372
+ end
365
373
 
366
374
  # relationship auto indexes
367
375
 
@@ -92,6 +92,9 @@ module Neography
92
92
  @connection.delete(value_path(:index => index, :id => get_id(id), :key => key, :value => value))
93
93
  end
94
94
 
95
+ def drop(index)
96
+ @connection.delete(base_path(:index => index))
97
+ end
95
98
  end
96
99
  end
97
100
  end
@@ -1,3 +1,3 @@
1
1
  module Neography
2
- VERSION = "1.1.3"
2
+ VERSION = "1.1.4"
3
3
  end
@@ -439,4 +439,30 @@ describe Neography::Rest do
439
439
 
440
440
  end
441
441
 
442
+ describe "drop index" do
443
+ it "can drop a node index" do
444
+ new_node = @neo.create_node
445
+ key = generate_text(6)
446
+ value = generate_text
447
+ @neo.add_node_to_index("test_node_index", key, value, new_node)
448
+ new_index = @neo.get_node_index("test_node_index", key, value)
449
+ new_index.should_not be_nil
450
+ @neo.drop_node_index("test_node_index")
451
+ expect { @neo.get_node_index("test_node_index", key, value) }.to raise_error Neography::NotFoundException
452
+ end
453
+
454
+ it "can get a relationship index" do
455
+ new_node1 = @neo.create_node
456
+ new_node2 = @neo.create_node
457
+ new_relationship = @neo.create_relationship("friends", new_node1, new_node2)
458
+ key = generate_text(6)
459
+ value = generate_text
460
+ @neo.add_relationship_to_index("test_relationship_index", key, value, new_relationship)
461
+ new_index = @neo.get_relationship_index("test_relationship_index", key, value)
462
+ new_index.should_not be_nil
463
+ @neo.drop_relationship_index("test_relationship_index")
464
+ expect { @neo.get_relationship_index("test_relationship_index", key, value) }.to raise_error Neography::NotFoundException
465
+ end
466
+ end
467
+
442
468
  end
data/spec/spec_helper.rb CHANGED
@@ -32,7 +32,7 @@ def error_response(attributes)
32
32
  http_header = double()
33
33
  http_header.stub(:request_uri).and_return(request_uri)
34
34
 
35
- stub(
35
+ double(
36
36
  http_header: http_header,
37
37
  code: attributes[:code],
38
38
  body: {
@@ -78,22 +78,22 @@ module Neography
78
78
  context "requests" do
79
79
 
80
80
  it "does a GET request" do
81
- connection.client.should_receive(:get).with("http://localhost:7474/db/data/foo/bar", nil, nil) { stub.as_null_object }
81
+ connection.client.should_receive(:get).with("http://localhost:7474/db/data/foo/bar", nil, nil) { double.as_null_object }
82
82
  connection.get("/foo/bar")
83
83
  end
84
84
 
85
85
  it "does a POST request" do
86
- connection.client.should_receive(:post).with("http://localhost:7474/db/data/foo/bar", nil, nil) { stub.as_null_object }
86
+ connection.client.should_receive(:post).with("http://localhost:7474/db/data/foo/bar", nil, nil) { double.as_null_object }
87
87
  connection.post("/foo/bar")
88
88
  end
89
89
 
90
90
  it "does a PUT request" do
91
- connection.client.should_receive(:put).with("http://localhost:7474/db/data/foo/bar", nil, nil) { stub.as_null_object }
91
+ connection.client.should_receive(:put).with("http://localhost:7474/db/data/foo/bar", nil, nil) { double.as_null_object }
92
92
  connection.put("/foo/bar")
93
93
  end
94
94
 
95
95
  it "does a DELETE request" do
96
- connection.client.should_receive(:delete).with("http://localhost:7474/db/data/foo/bar", nil, nil) { stub.as_null_object }
96
+ connection.client.should_receive(:delete).with("http://localhost:7474/db/data/foo/bar", nil, nil) { double.as_null_object }
97
97
  connection.delete("/foo/bar")
98
98
  end
99
99
 
@@ -110,11 +110,11 @@ module Neography
110
110
  connection.client.should_receive(:set_auth).with(
111
111
  "http://localhost:7474/db/data/foo/bar",
112
112
  "foo",
113
- "bar") { stub.as_null_object }
113
+ "bar") { double.as_null_object }
114
114
 
115
115
  connection.client.should_receive(:get).with(
116
116
  "http://localhost:7474/db/data/foo/bar", nil, nil
117
- ) { stub.as_null_object }
117
+ ) { double.as_null_object }
118
118
 
119
119
  connection.get("/foo/bar")
120
120
  end
@@ -124,7 +124,7 @@ module Neography
124
124
  connection.client.should_receive(:get).with(
125
125
  "http://localhost:7474/db/data/foo/bar",
126
126
  nil, { "User-Agent" => "Neography/#{Neography::VERSION}", "X-Stream"=>true}
127
- ) { stub.as_null_object }
127
+ ) { double.as_null_object }
128
128
 
129
129
  connection.get("/foo/bar", :headers => {})
130
130
  end
@@ -7,7 +7,7 @@ module Neography
7
7
  context "no explicit server" do
8
8
 
9
9
  before do
10
- @db = mock(Neography::Rest, :is_a? => true).as_null_object
10
+ @db = double(Neography::Rest, :is_a? => true).as_null_object
11
11
  Rest.stub(:new) { @db }
12
12
  end
13
13
 
@@ -55,7 +55,7 @@ module Neography
55
55
 
56
56
  before do
57
57
  # stub out actual connections
58
- @db = stub(Rest).as_null_object
58
+ @db = double(Rest).as_null_object
59
59
  Rest.stub(:new) { @db }
60
60
  end
61
61
 
@@ -4,7 +4,7 @@ module Neography
4
4
  describe "Properties" do
5
5
 
6
6
  before do
7
- @db = mock(Neography::Rest, :is_a? => true).as_null_object
7
+ @db = double(Neography::Rest, :is_a? => true).as_null_object
8
8
  Rest.stub(:new) { @db }
9
9
  end
10
10
 
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  module Neography
4
4
  describe Relationship do
5
5
 
6
- let(:db) { stub(Rest).as_null_object }
6
+ let(:db) { double(Rest).as_null_object }
7
7
  let(:relationship_hash) do
8
8
  {
9
9
  "self" => "0",
@@ -13,8 +13,8 @@ module Neography
13
13
  }
14
14
  end
15
15
 
16
- let(:from) { stub(:neo_server => db) }
17
- let(:to) { stub(:neo_server => db) }
16
+ let(:from) { double(:neo_server => db) }
17
+ let(:to) { double(:neo_server => db) }
18
18
  let(:props) { { :foo => "bar" } }
19
19
 
20
20
  describe "::create" do
@@ -40,7 +40,7 @@ module Neography
40
40
 
41
41
  before do
42
42
  # stub out actual connections
43
- @db = stub(Rest).as_null_object
43
+ @db = double(Rest).as_null_object
44
44
  Rest.stub(:new) { @db }
45
45
  end
46
46
 
@@ -4,7 +4,7 @@ module Neography
4
4
  class Rest
5
5
  describe Batch do
6
6
 
7
- let(:connection) { stub(:gremlin_path => "/gremlin", :cypher_path => "/cypher") }
7
+ let(:connection) { double(:gremlin_path => "/gremlin", :cypher_path => "/cypher") }
8
8
  subject { Batch.new(connection) }
9
9
 
10
10
  it "gets nodes" do
@@ -4,7 +4,7 @@ module Neography
4
4
  class Rest
5
5
  describe Clean do
6
6
 
7
- let(:connection) { stub }
7
+ let(:connection) { double }
8
8
  subject { Clean.new(connection) }
9
9
 
10
10
  it "cleans the database" do
@@ -4,7 +4,7 @@ module Neography
4
4
  class Rest
5
5
  describe Cypher do
6
6
 
7
- let(:connection) { stub(:cypher_path => "/cypher") }
7
+ let(:connection) { double(:cypher_path => "/cypher") }
8
8
  subject { Cypher.new(connection) }
9
9
 
10
10
  it "executes a cypher query" do
@@ -4,7 +4,7 @@ module Neography
4
4
  class Rest
5
5
  describe Extensions do
6
6
 
7
- let(:connection) { stub }
7
+ let(:connection) { double }
8
8
  subject { Extensions.new(connection) }
9
9
 
10
10
  it "executes an extensions get query" do
@@ -4,7 +4,7 @@ module Neography
4
4
  class Rest
5
5
  describe Gremlin do
6
6
 
7
- let(:connection) { stub(:gremlin_path => "/gremlin") }
7
+ let(:connection) { double(:gremlin_path => "/gremlin") }
8
8
  subject { Gremlin.new(connection) }
9
9
 
10
10
  it "executes a gremlin script" do
@@ -4,7 +4,7 @@ module Neography
4
4
  class Rest
5
5
  describe NodeLabels do
6
6
 
7
- let(:connection) { stub }
7
+ let(:connection) { double }
8
8
  subject { NodeLabels.new(connection) }
9
9
 
10
10
  it "list node labels" do
@@ -4,7 +4,7 @@ module Neography
4
4
  class Rest
5
5
  describe NodeAutoIndexes do
6
6
 
7
- let(:connection) { stub }
7
+ let(:connection) { double }
8
8
  subject { NodeAutoIndexes.new(connection) }
9
9
 
10
10
  it "gets a node from an auto index" do
@@ -4,7 +4,7 @@ module Neography
4
4
  class Rest
5
5
  describe NodeIndexes do
6
6
 
7
- let(:connection) { stub(:configuration => "http://configuration") }
7
+ let(:connection) { double(:configuration => "http://configuration") }
8
8
  subject { NodeIndexes.new(connection) }
9
9
 
10
10
  it "lists all indexes" do
@@ -131,6 +131,11 @@ module Neography
131
131
  subject.remove_by_value("some_index", "42", "some_key", "some_value")
132
132
  end
133
133
 
134
+ it "drops an index" do
135
+ connection.should_receive(:delete).with("/index/node/some_index")
136
+ subject.drop("some_index")
137
+ end
138
+
134
139
  end
135
140
  end
136
141
  end
@@ -4,7 +4,7 @@ module Neography
4
4
  class Rest
5
5
  describe NodePaths do
6
6
 
7
- let(:connection) { stub(:configuration => "http://configuration") }
7
+ let(:connection) { double(:configuration => "http://configuration") }
8
8
  subject { NodePaths.new(connection) }
9
9
 
10
10
  it "gets a shortest path between two nodes" do
@@ -4,7 +4,7 @@ module Neography
4
4
  class Rest
5
5
  describe NodeProperties do
6
6
 
7
- let(:connection) { stub }
7
+ let(:connection) { double }
8
8
  subject { NodeProperties.new(connection) }
9
9
 
10
10
  it "sets properties" do
@@ -4,7 +4,7 @@ module Neography
4
4
  class Rest
5
5
  describe NodeRelationships do
6
6
 
7
- let(:connection) { stub(:configuration => "http://configuration") }
7
+ let(:connection) { double(:configuration => "http://configuration") }
8
8
  subject { NodeRelationships.new(connection) }
9
9
 
10
10
  it "creates a relationship" do
@@ -4,7 +4,7 @@ module Neography
4
4
  class Rest
5
5
  describe NodeTraversal do
6
6
 
7
- let(:connection) { stub }
7
+ let(:connection) { double }
8
8
  subject { NodeTraversal.new(connection) }
9
9
 
10
10
  it "traverses" do
@@ -4,7 +4,7 @@ module Neography
4
4
  class Rest
5
5
  describe Nodes do
6
6
 
7
- let(:connection) { stub }
7
+ let(:connection) { double }
8
8
  subject { Nodes.new(connection) }
9
9
 
10
10
  context "get nodes" do
@@ -141,7 +141,7 @@ module Neography
141
141
 
142
142
  context "#create_multiple_threaded" do
143
143
 
144
- let(:connection) { stub(:max_threads => 2) }
144
+ let(:connection) { double(:max_threads => 2) }
145
145
 
146
146
  it "creates multiple with attributes" do
147
147
  options1 = {
@@ -4,7 +4,7 @@ module Neography
4
4
  class Rest
5
5
  describe RelationshipAutoIndexes do
6
6
 
7
- let(:connection) { stub }
7
+ let(:connection) { double }
8
8
  subject { RelationshipAutoIndexes.new(connection) }
9
9
 
10
10
  it "gets a relationship from an auto index" do
@@ -4,7 +4,7 @@ module Neography
4
4
  class Rest
5
5
  describe RelationshipIndexes do
6
6
 
7
- let(:connection) { stub(:configuration => "http://configuration") }
7
+ let(:connection) { double(:configuration => "http://configuration") }
8
8
  subject { RelationshipIndexes.new(connection) }
9
9
 
10
10
  it "lists all indexes" do
@@ -123,6 +123,10 @@ module Neography
123
123
  subject.remove_by_value("some_index", "42", "some_key", "some_value")
124
124
  end
125
125
 
126
+ it "drops an index" do
127
+ connection.should_receive(:delete).with("/index/relationship/some_index")
128
+ subject.drop("some_index")
129
+ end
126
130
  end
127
131
  end
128
132
  end
@@ -4,7 +4,7 @@ module Neography
4
4
  class Rest
5
5
  describe RelationshipProperties do
6
6
 
7
- let(:connection) { stub }
7
+ let(:connection) { double }
8
8
  subject { RelationshipProperties.new(connection) }
9
9
 
10
10
  it "sets properties" do
@@ -4,7 +4,7 @@ module Neography
4
4
  class Rest
5
5
  describe RelationshipTypes do
6
6
 
7
- let(:connection) { stub(:configuration => "http://configuration") }
7
+ let(:connection) { double(:configuration => "http://configuration") }
8
8
  subject { RelationshipTypes.new(connection) }
9
9
 
10
10
  it "lists all relationship types" do
@@ -4,7 +4,7 @@ module Neography
4
4
  class Rest
5
5
  describe Relationships do
6
6
 
7
- let(:connection) { stub }
7
+ let(:connection) { double }
8
8
  subject { Relationships.new(connection) }
9
9
 
10
10
  it "gets a relationship" do
@@ -4,7 +4,7 @@ module Neography
4
4
  class Rest
5
5
  describe SchemaIndexes do
6
6
 
7
- let(:connection) { stub(:configuration => "http://configuration") }
7
+ let(:connection) { double(:configuration => "http://configuration") }
8
8
  subject { SchemaIndexes.new(connection) }
9
9
 
10
10
  it "create schema indexes" do
@@ -4,7 +4,7 @@ module Neography
4
4
  class Rest
5
5
  describe Transactions do
6
6
 
7
- let(:connection) { stub(:configuration => "http://configuration") }
7
+ let(:connection) { double(:configuration => "http://configuration") }
8
8
  subject { Transactions.new(connection) }
9
9
 
10
10
  it "can create new transactions" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: neography
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.1.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: