neography-down 1.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/.project +12 -0
  4. data/.rspec +1 -0
  5. data/.travis.yml +4 -0
  6. data/CHANGELOG.md +939 -0
  7. data/CONTRIBUTORS +18 -0
  8. data/Gemfile +4 -0
  9. data/Guardfile +14 -0
  10. data/LICENSE +19 -0
  11. data/README.md +281 -0
  12. data/Rakefile +14 -0
  13. data/examples/facebook.rb +40 -0
  14. data/examples/facebook_v2.rb +25 -0
  15. data/examples/greatest.rb +43 -0
  16. data/examples/linkedin.rb +39 -0
  17. data/examples/linkedin_v2.rb +22 -0
  18. data/examples/traversal_example1.rb +65 -0
  19. data/examples/traversal_example2.rb +54 -0
  20. data/lib/neography.rb +45 -0
  21. data/lib/neography/config.rb +64 -0
  22. data/lib/neography/connection.rb +263 -0
  23. data/lib/neography/equal.rb +21 -0
  24. data/lib/neography/errors.rb +60 -0
  25. data/lib/neography/index.rb +52 -0
  26. data/lib/neography/multi_json_parser.rb +28 -0
  27. data/lib/neography/neography.rb +10 -0
  28. data/lib/neography/node.rb +63 -0
  29. data/lib/neography/node_path.rb +29 -0
  30. data/lib/neography/node_relationship.rb +37 -0
  31. data/lib/neography/node_traverser.rb +146 -0
  32. data/lib/neography/path_traverser.rb +100 -0
  33. data/lib/neography/property.rb +110 -0
  34. data/lib/neography/property_container.rb +28 -0
  35. data/lib/neography/railtie.rb +19 -0
  36. data/lib/neography/relationship.rb +78 -0
  37. data/lib/neography/relationship_traverser.rb +80 -0
  38. data/lib/neography/rest.rb +99 -0
  39. data/lib/neography/rest/batch.rb +414 -0
  40. data/lib/neography/rest/clean.rb +17 -0
  41. data/lib/neography/rest/constraints.rb +38 -0
  42. data/lib/neography/rest/cypher.rb +29 -0
  43. data/lib/neography/rest/extensions.rb +21 -0
  44. data/lib/neography/rest/gremlin.rb +20 -0
  45. data/lib/neography/rest/helpers.rb +96 -0
  46. data/lib/neography/rest/node_auto_indexes.rb +60 -0
  47. data/lib/neography/rest/node_indexes.rb +139 -0
  48. data/lib/neography/rest/node_labels.rb +49 -0
  49. data/lib/neography/rest/node_paths.rb +49 -0
  50. data/lib/neography/rest/node_properties.rb +52 -0
  51. data/lib/neography/rest/node_relationships.rb +33 -0
  52. data/lib/neography/rest/node_traversal.rb +25 -0
  53. data/lib/neography/rest/nodes.rb +94 -0
  54. data/lib/neography/rest/other_node_relationships.rb +38 -0
  55. data/lib/neography/rest/relationship_auto_indexes.rb +60 -0
  56. data/lib/neography/rest/relationship_indexes.rb +142 -0
  57. data/lib/neography/rest/relationship_properties.rb +52 -0
  58. data/lib/neography/rest/relationship_types.rb +11 -0
  59. data/lib/neography/rest/relationships.rb +16 -0
  60. data/lib/neography/rest/schema_indexes.rb +26 -0
  61. data/lib/neography/rest/spatial.rb +137 -0
  62. data/lib/neography/rest/transactions.rb +101 -0
  63. data/lib/neography/tasks.rb +207 -0
  64. data/lib/neography/version.rb +3 -0
  65. data/neography.gemspec +39 -0
  66. data/spec/integration/authorization_spec.rb +40 -0
  67. data/spec/integration/broken_spatial_spec.rb +28 -0
  68. data/spec/integration/index_spec.rb +71 -0
  69. data/spec/integration/neography_spec.rb +10 -0
  70. data/spec/integration/node_encoding_spec.rb +71 -0
  71. data/spec/integration/node_path_spec.rb +222 -0
  72. data/spec/integration/node_relationship_spec.rb +381 -0
  73. data/spec/integration/node_spec.rb +260 -0
  74. data/spec/integration/parsing_spec.rb +13 -0
  75. data/spec/integration/performance_spec.rb +17 -0
  76. data/spec/integration/relationship_spec.rb +37 -0
  77. data/spec/integration/rest_batch_no_streaming_spec.rb +41 -0
  78. data/spec/integration/rest_batch_spec.rb +604 -0
  79. data/spec/integration/rest_batch_streaming_spec.rb +51 -0
  80. data/spec/integration/rest_bulk_spec.rb +106 -0
  81. data/spec/integration/rest_constraints_spec.rb +72 -0
  82. data/spec/integration/rest_experimental_spec.rb +22 -0
  83. data/spec/integration/rest_gremlin_fail_spec.rb +46 -0
  84. data/spec/integration/rest_header_spec.rb +15 -0
  85. data/spec/integration/rest_index_spec.rb +481 -0
  86. data/spec/integration/rest_labels_spec.rb +128 -0
  87. data/spec/integration/rest_node_spec.rb +274 -0
  88. data/spec/integration/rest_other_node_relationship_spec.rb +137 -0
  89. data/spec/integration/rest_path_spec.rb +231 -0
  90. data/spec/integration/rest_plugin_spec.rb +177 -0
  91. data/spec/integration/rest_relationship_spec.rb +354 -0
  92. data/spec/integration/rest_relationship_types_spec.rb +18 -0
  93. data/spec/integration/rest_schema_index_spec.rb +32 -0
  94. data/spec/integration/rest_spatial_spec.rb +166 -0
  95. data/spec/integration/rest_transaction_spec.rb +166 -0
  96. data/spec/integration/rest_traverse_spec.rb +149 -0
  97. data/spec/integration/unmanaged_spec.rb +27 -0
  98. data/spec/matchers.rb +33 -0
  99. data/spec/neography_spec.rb +23 -0
  100. data/spec/spec_helper.rb +44 -0
  101. data/spec/unit/config_spec.rb +135 -0
  102. data/spec/unit/connection_spec.rb +284 -0
  103. data/spec/unit/node_spec.rb +100 -0
  104. data/spec/unit/properties_spec.rb +285 -0
  105. data/spec/unit/relationship_spec.rb +118 -0
  106. data/spec/unit/rest/batch_spec.rb +262 -0
  107. data/spec/unit/rest/clean_spec.rb +16 -0
  108. data/spec/unit/rest/constraints_spec.rb +45 -0
  109. data/spec/unit/rest/cypher_spec.rb +20 -0
  110. data/spec/unit/rest/extensions_spec.rb +28 -0
  111. data/spec/unit/rest/gremlin_spec.rb +25 -0
  112. data/spec/unit/rest/helpers_spec.rb +124 -0
  113. data/spec/unit/rest/labels_spec.rb +77 -0
  114. data/spec/unit/rest/node_auto_indexes_spec.rb +70 -0
  115. data/spec/unit/rest/node_indexes_spec.rb +140 -0
  116. data/spec/unit/rest/node_paths_spec.rb +77 -0
  117. data/spec/unit/rest/node_properties_spec.rb +79 -0
  118. data/spec/unit/rest/node_relationships_spec.rb +57 -0
  119. data/spec/unit/rest/node_traversal_spec.rb +35 -0
  120. data/spec/unit/rest/nodes_spec.rb +187 -0
  121. data/spec/unit/rest/relationship_auto_indexes_spec.rb +66 -0
  122. data/spec/unit/rest/relationship_indexes_spec.rb +132 -0
  123. data/spec/unit/rest/relationship_properties_spec.rb +79 -0
  124. data/spec/unit/rest/relationship_types_spec.rb +15 -0
  125. data/spec/unit/rest/relationships_spec.rb +21 -0
  126. data/spec/unit/rest/schema_index_spec.rb +30 -0
  127. data/spec/unit/rest/transactions_spec.rb +43 -0
  128. metadata +372 -0
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ describe Neography::Rest do
4
+ before(:each) do
5
+ @neo = Neography::Rest.new
6
+ end
7
+
8
+ describe "call unmanaged extensions", :unmanaged_extensions => true do
9
+ it "can call a get based unmanaged extension" do
10
+ results = @neo.get_extension('/example/service/queries/fofof/13343')
11
+ expect(results).not_to be_null
12
+ end
13
+
14
+ it "can call a POST based unmanaged extension" do
15
+ results = @neo.post_extention('/movie/recommend', {"title" => "Rambo"})
16
+ expect(results).not_to be_null
17
+ end
18
+
19
+ it "can call a POST based unmanaged extension that uses form-urlencoded" do
20
+ headers = {'Content-Type' =>'application/x-www-form-urlencoded'}
21
+ results = @neo.post_extention('/music/recommend', {"artist" => "Ministry", "song" => "Just one Fix"}, headers)
22
+ expect(results).not_to be_null
23
+ end
24
+
25
+ end
26
+
27
+ end
data/spec/matchers.rb ADDED
@@ -0,0 +1,33 @@
1
+ # Convenience matcher for matching JSON fields with a hash
2
+ RSpec::Matchers.define :json_match do |field, expected|
3
+
4
+ match do |actual|
5
+ expected == JSON.parse(actual[field])
6
+ end
7
+
8
+ failure_message do
9
+ "expected JSON in field '#{field}' to match '#{expected}'"
10
+ end
11
+
12
+ description do
13
+ "JSON in field '#{field}' should match '#{expected.inspect}'"
14
+ end
15
+
16
+ end
17
+
18
+ # Convenience matcher for matching fields in a hash
19
+ RSpec::Matchers.define :hash_match do |field, expected|
20
+
21
+ match do |actual|
22
+ expected == actual[field]
23
+ end
24
+
25
+ failure_message do
26
+ "expected field '#{field}' to match '#{expected}'"
27
+ end
28
+
29
+ description do
30
+ "field '#{field}' should match '#{expected.inspect}'"
31
+ end
32
+
33
+ end
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+
3
+ describe Neography do
4
+
5
+ describe "::configure" do
6
+
7
+ it "returns the same configuration" do
8
+ expect(Neography.configuration).to eq(Neography.configuration)
9
+ end
10
+
11
+ it "returns the Config" do
12
+ expect(Neography.configuration).to be_a Neography::Config
13
+ end
14
+
15
+ it "yields the configuration" do
16
+ Neography.configure do |config|
17
+ expect(config).to eq(Neography.configuration)
18
+ end
19
+ end
20
+
21
+ end
22
+
23
+ end
@@ -0,0 +1,44 @@
1
+ require 'neography'
2
+ require 'benchmark'
3
+ require 'matchers'
4
+ require 'coveralls'
5
+ Coveralls.wear!
6
+
7
+ # If you want to see more, uncomment the next few lines
8
+ # require 'net-http-spy'
9
+ # Net::HTTP.http_logger_options = {:body => true} # just the body
10
+ # Net::HTTP.http_logger_options = {:verbose => true} # see everything
11
+
12
+ def generate_text(length=8)
13
+ chars = 'abcdefghjkmnpqrstuvwxyz'
14
+ key = ''
15
+ length.times { |i| key << chars[rand(chars.length)] }
16
+ key
17
+ end
18
+
19
+ RSpec.configure do |c|
20
+ c.filter_run_excluding :slow => true, :gremlin => true, :reference => true, :neo_is_broken => true, :unmanaged_extensions => true
21
+ end
22
+
23
+
24
+ def json_content_type
25
+ {"Content-Type"=>"application/json"}
26
+ end
27
+
28
+ def error_response(attributes)
29
+ request_uri = double()
30
+ allow(request_uri).to receive(:request_uri).and_return("")
31
+
32
+ http_header = double()
33
+ allow(http_header).to receive(:request_uri).and_return(request_uri)
34
+
35
+ double(
36
+ http_header: http_header,
37
+ status: attributes[:code],
38
+ body: {
39
+ message: attributes[:message],
40
+ exception: attributes[:exception],
41
+ stacktrace: attributes[:stacktrace]
42
+ }.reject { |k,v| v.nil? }.to_json
43
+ )
44
+ end
@@ -0,0 +1,135 @@
1
+ require 'spec_helper'
2
+
3
+ module Neography
4
+ describe Config do
5
+
6
+ subject(:config) { Config.new }
7
+
8
+ context "defaults" do
9
+
10
+ describe '#protocol' do
11
+ subject { super().protocol }
12
+ it { should == 'http://' }
13
+ end
14
+
15
+ describe '#server' do
16
+ subject { super().server }
17
+ it { should == 'localhost' }
18
+ end
19
+
20
+ describe '#port' do
21
+ subject { super().port }
22
+ it { should == 7474 }
23
+ end
24
+
25
+ describe '#directory' do
26
+ subject { super().directory }
27
+ it { should == '' }
28
+ end
29
+
30
+ describe '#cypher_path' do
31
+ subject { super().cypher_path }
32
+ it { should == '/cypher' }
33
+ end
34
+
35
+ describe '#gremlin_path' do
36
+ subject { super().gremlin_path }
37
+ it { should == '/ext/GremlinPlugin/graphdb/execute_script' }
38
+ end
39
+
40
+ describe '#log_file' do
41
+ subject { super().log_file }
42
+ it { should == 'neography.log' }
43
+ end
44
+
45
+ describe '#log_enabled' do
46
+ subject { super().log_enabled }
47
+ it { should == false }
48
+ end
49
+
50
+ describe '#logger' do
51
+ subject { super().logger }
52
+ it { should == nil }
53
+ end
54
+
55
+ describe '#slow_log_threshold' do
56
+ subject { super().slow_log_threshold }
57
+ it { should == 0 }
58
+ end
59
+
60
+ describe '#max_threads' do
61
+ subject { super().max_threads }
62
+ it { should == 20 }
63
+ end
64
+
65
+ describe '#authentication' do
66
+ subject { super().authentication }
67
+ it { should == nil }
68
+ end
69
+
70
+ describe '#username' do
71
+ subject { super().username }
72
+ it { should == nil }
73
+ end
74
+
75
+ describe '#password' do
76
+ subject { super().password }
77
+ it { should == nil }
78
+ end
79
+
80
+ describe '#parser' do
81
+ subject { super().parser }
82
+ it { should == MultiJsonParser}
83
+ end
84
+
85
+ describe '#max_execution_time' do
86
+ subject { super().max_execution_time }
87
+ it { should == 6000 }
88
+ end
89
+
90
+ describe '#proxy' do
91
+ subject { super().proxy }
92
+ it { should == nil }
93
+ end
94
+
95
+ describe '#http_send_timeout' do
96
+ subject { super().http_send_timeout }
97
+ it { should == 1200 }
98
+ end
99
+
100
+ describe '#http_receive_timeout' do
101
+ subject { super().http_receive_timeout }
102
+ it { should == 1200 }
103
+ end
104
+
105
+
106
+ it "has a hash representation" do
107
+ expected_hash = {
108
+ :protocol => 'http://',
109
+ :server => 'localhost',
110
+ :port => 7474,
111
+ :directory => '',
112
+ :cypher_path => '/cypher',
113
+ :gremlin_path => '/ext/GremlinPlugin/graphdb/execute_script',
114
+ :log_file => 'neography.log',
115
+ :log_enabled => false,
116
+ :logger => nil,
117
+ :slow_log_threshold => 0,
118
+ :max_threads => 20,
119
+ :authentication => nil,
120
+ :username => nil,
121
+ :password => nil,
122
+ :parser => MultiJsonParser,
123
+ :max_execution_time => 6000,
124
+ :proxy => nil,
125
+ :http_send_timeout => 1200,
126
+ :http_receive_timeout => 1200
127
+
128
+ }
129
+ expect(config.to_hash).to eq(expected_hash)
130
+ end
131
+
132
+ end
133
+
134
+ end
135
+ end
@@ -0,0 +1,284 @@
1
+ require 'spec_helper'
2
+
3
+ module Neography
4
+ describe Connection do
5
+
6
+ subject(:connection) { Connection.new }
7
+
8
+ context "defaults" do
9
+
10
+ it "intializes with defaults" do
11
+ expect(connection.configuration).to eq("http://localhost:7474")
12
+ end
13
+
14
+ end
15
+
16
+ context "custom options" do
17
+
18
+ subject(:connection) { Connection.new(options) }
19
+
20
+ context "hash options" do
21
+ let(:options) do
22
+ {
23
+ :protocol => "https://",
24
+ :server => "foobar",
25
+ :port => 4242,
26
+ :directory => "/dir",
27
+ :cypher_path => "/cyph",
28
+ :gremlin_path => "/grem",
29
+ :log_file => "neo.log",
30
+ :log_enabled => false,
31
+ :slow_log_threshold => 0,
32
+ :max_threads => 10,
33
+ :parser => Foo,
34
+ :authentication => "foo",
35
+ :username => "bar",
36
+ :password => "baz"
37
+ }
38
+ end
39
+
40
+ it "accepts all options in a hash" do
41
+ expect(connection.configuration).to eq("https://foobar:4242/dir")
42
+
43
+ expect(connection.protocol).to eq("https://")
44
+ expect(connection.server).to eq("foobar")
45
+ expect(connection.port).to eq(4242)
46
+ expect(connection.directory).to eq("/dir")
47
+ expect(connection.cypher_path).to eq("/cyph")
48
+ expect(connection.gremlin_path).to eq("/grem")
49
+ expect(connection.log_file).to eq("neo.log")
50
+ expect(connection.log_enabled).to eq(false)
51
+ expect(connection.slow_log_threshold).to eq(0)
52
+ expect(connection.max_threads).to eq(10)
53
+ expect(connection.parser).to eq(Foo)
54
+
55
+ expect(connection.authentication).to eq({
56
+ :foo_auth => {
57
+ :username => "bar",
58
+ :password => "baz"
59
+ }
60
+ })
61
+ end
62
+
63
+ context "httpclient" do
64
+ let(:httpclient) { double(:http_client) }
65
+ let(:options) do
66
+ {
67
+ :http_send_timeout => 120,
68
+ :http_receive_timeout => 100
69
+ }
70
+ end
71
+
72
+ it 'configures send/receive timeout' do
73
+ expect(Excon).to receive(:new).with("http://localhost:7474",
74
+ :read_timeout => 100,
75
+ :write_timeout => 120,
76
+ :persistent=>true,
77
+ :user=>nil,
78
+ :password=>nil).and_return(httpclient)
79
+ connection
80
+ end
81
+ end
82
+ end
83
+
84
+
85
+
86
+ context "string option" do
87
+ let(:options) { "https://user:pass@somehost:8585/path" }
88
+
89
+ it "accepts a string as configuration" do
90
+ expect(connection.configuration).to eq("https://somehost:8585/path")
91
+ expect(connection.authentication).to eq({
92
+ :basic_auth => {
93
+ :username => "user",
94
+ :password => "pass"
95
+ }
96
+ })
97
+ end
98
+ end
99
+
100
+ end
101
+
102
+ context "requests" do
103
+
104
+ it "does a GET request" do
105
+ expect(connection.client).to receive(:request).with(:method => :get, :path => "/db/data/node/bar", :body => nil, :headers => nil) { double.as_null_object }
106
+ connection.get("/node/bar")
107
+ end
108
+
109
+ it "does a POST request" do
110
+ expect(connection.client).to receive(:request).with(:method => :post, :path => "/db/data/node/bar", :body => nil, :headers => nil) { double.as_null_object }
111
+ connection.post("/node/bar")
112
+ end
113
+
114
+ it "does a PUT request" do
115
+ expect(connection.client).to receive(:request).with(:method => :put, :path => "/db/data/node/bar", :body => nil, :headers => nil) { double.as_null_object }
116
+ connection.put("/node/bar")
117
+ end
118
+
119
+ it "does a DELETE request" do
120
+ expect(connection.client).to receive(:request).with(:method => :delete, :path => "/db/data/node/bar", :body => nil, :headers => nil) { double.as_null_object }
121
+ connection.delete("/node/bar")
122
+ end
123
+
124
+ context "authentication" do
125
+ subject(:connection) do
126
+ Connection.new({
127
+ :authentication => "basic",
128
+ :username => "foo",
129
+ :password => "bar"
130
+ })
131
+ end
132
+
133
+ it "does requests with authentication" do
134
+ expect(connection.client).not_to receive(:set_auth).with(
135
+ "http://localhost:7474/db/data/node/bar",
136
+ "foo",
137
+ "bar") { double.as_null_object }
138
+
139
+ expect(connection.client).to receive(:request).with(
140
+ :method => :get, :path => "/db/data/node/bar", :body => nil, :headers => nil) { double.as_null_object }
141
+
142
+ connection.get("/node/bar")
143
+ end
144
+ end
145
+
146
+ it "adds the User-Agent to the headers" do
147
+ expect(connection.client).to receive(:request).with(
148
+ hash_including(
149
+ {:method => :get, :path => "/db/data/node/bar", :body => nil,
150
+ :headers => {"User-Agent" => "Neography/#{Neography::VERSION}", "X-Stream"=>true, "max-execution-time" => 6000}}
151
+ )
152
+ ) { double.as_null_object }
153
+
154
+ connection.get("/node/bar", :headers => {})
155
+ end
156
+
157
+ context "errors" do
158
+
159
+ it "raises NodeNotFoundException" do
160
+ response = error_response(code: 404, message: "a message", exception: "NodeNotFoundException")
161
+ allow(connection.client).to receive(:request).and_return(response)
162
+ expect {
163
+ connection.get("/node/bar")
164
+ }.to raise_error NodeNotFoundException
165
+ end
166
+
167
+ it "raises OperationFailureException" do
168
+ response = error_response(code: 409, message: "a message", exception: "OperationFailureException")
169
+ allow(connection.client).to receive(:request).and_return(response)
170
+ expect {
171
+ connection.get("/node/bar")
172
+ }.to raise_error OperationFailureException
173
+ end
174
+
175
+ it "raises PropertyValueException" do
176
+ response = error_response(code: 400, message: "a message", exception: "PropertyValueException")
177
+ allow(connection.client).to receive(:request).and_return(response)
178
+ expect {
179
+ connection.get("/node/bar")
180
+ }.to raise_error PropertyValueException
181
+ end
182
+
183
+ it "raises NoSuchPropertyException" do
184
+ response = error_response(code: 404, message: "a message", exception: "NoSuchPropertyException")
185
+ allow(connection.client).to receive(:request).and_return(response)
186
+ expect {
187
+ connection.get("/node/bar")
188
+ }.to raise_error NoSuchPropertyException
189
+ end
190
+
191
+ it "raises RelationshipNotFoundException" do
192
+ response = error_response(code: 404, message: "a message", exception: "RelationshipNotFoundException")
193
+ allow(connection.client).to receive(:request).and_return(response)
194
+ expect {
195
+ connection.get("/node/bar")
196
+ }.to raise_error RelationshipNotFoundException
197
+ end
198
+
199
+ it "raises BadInputException" do
200
+ response = error_response(code: 400, message: "a message", exception: "BadInputException")
201
+ allow(connection.client).to receive(:request).and_return(response)
202
+ expect {
203
+ connection.get("/node/bar")
204
+ }.to raise_error BadInputException
205
+ end
206
+
207
+ it "raises UnauthorizedError" do
208
+ response = error_response(code: 401)
209
+ allow(connection.client).to receive(:request).and_return(response)
210
+ expect {
211
+ connection.get("/node/bar")
212
+ }.to raise_error UnauthorizedError
213
+ end
214
+
215
+ it "raises NeographyError in all other cases" do
216
+ response = error_response(code: 418, message: "I'm a teapot.")
217
+ allow(connection.client).to receive(:request).and_return(response)
218
+ expect {
219
+ connection.get("/node/bar")
220
+ }.to raise_error NeographyError
221
+ end
222
+
223
+ it "raises BadInputException" do
224
+ response = error_response(code: 500, message: "a message", exception: "JsonParseException")
225
+ allow(connection.client).to receive(:request).and_return(response)
226
+ expect {
227
+ connection.get("/node/bar")
228
+ }.to raise_error NeographyError
229
+ end
230
+
231
+ end
232
+
233
+ context "query logging" do
234
+
235
+ subject(:connection) do
236
+
237
+ Connection.new({
238
+ :logger => Logger.new(nil),
239
+ :log_enabled => true
240
+ })
241
+
242
+ let(:expected_response) {"expected_response"}
243
+
244
+ let(:request_body) { {key1: :val1} }
245
+
246
+ it "should log query" do
247
+ connection.should_receive(:log).with("/db/data/node/bar", request_body).once
248
+ connection.get("/node/bar", {body: request_body})
249
+ end
250
+
251
+ it "should return original response" do
252
+ connection.stub(:evaluate_response).and_return expected_response
253
+ connection.get("/node/bar").should eq expected_response
254
+ end
255
+
256
+ describe "slow_log_threshold" do
257
+ before do
258
+ allow(connection).to receive(:evaluate_response).and_return expected_response
259
+ end
260
+
261
+ context "default value" do
262
+ it "should have output" do
263
+ expect(@logger).to receive(:info).once
264
+ end
265
+ end
266
+
267
+ context "high value" do
268
+ before { connection.slow_log_threshold = 100_000 }
269
+ it "should not have output" do
270
+ expect(@logger).not_to receive(:info)
271
+ end
272
+ end
273
+
274
+ after do
275
+ connection.get("/node/bar", {body: request_body})
276
+ end
277
+ end
278
+ end
279
+ end
280
+ end
281
+ end
282
+ end
283
+
284
+ class Foo; end