繁体   English   中英

无法运行Neo4j支持的Rails应用程序的ruby规格测试

[英]Unable to run ruby spec tests of rails app backed by neo4j

我最近继承了由neo4j(而不是postgres)支持的Rails应用程序。

当我尝试运行像这样的规格测试时

NEO4J_TYPE=bolt NEO4J_URL="bolt://localhost" bundle exec rake spec

我懂了

/Users/user1/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/faraday-0.9.2/lib/faraday/adapter/net_http.rb:66:in `create_request': undefined method `request_uri' for #<URI::Generic bolt://localhost> (NoMethodError)

我也试过

NEO4J_TYPE=bolt NEO4J_URL="bolt://localhost:7687" bundle exec rake spec

我阅读了http://neo4jrb.readthedocs.io/en/7.1.x/Setup.htmlhttp://neo4jrb.readthedocs.io/en/9.0.x/Testing.html

但尚未找到解决方案。

我已经完成的一些事情:

brew install neo4j. # also installed java 8 with brew
rake neo4j:config[test,7575]
brew services stop neo4j
brew services start neo4j

$ cypher-shell -a bolt://localhost
Connected to Neo4j 3.3.0 at bolt://localhost:7687.
Type :help for a list of available commands or :exit to exit the shell.
Note that Cypher queries must end with a semicolon.
neo4j> 
Interrupted (Note that Cypher queries must end with a semicolon. Type :exit to exit the shell.)
neo4j> 

这与您定义URL的方式有关。 您正在使用bolt方案,因此URI不知道它是什么类型的URI,因此确实提供了通用URI实例。

bolt_uri = URI.parse("bolt://localhost") #=> #<URI::Generic bolt://localhost>
bolt_uri.request_uri #=> Raises NoMethodError

http_uri = URI.parse("http://localhost") #=> #<URI::HTTP http://localhost>
http_uri.request_uri #=> "/"

本质上,因为接口是通过HTTP并传递给Faraday(HTTP客户端)的,所以URL应该定义为NEO4J_URL="http://localhost"

关于Daniel的答案,gem应该允许使用bolt://作为URL(请参阅joshsverns链接到的Setup文档)。 该模式在这里找到:

https://github.com/neo4jrb/neo4j/blob/master/lib/neo4j/railtie.rb#L98

在上面的行中,它调用scheme来使bolt脱离URL。 另外,您可以从那里看到指定NEO4J_URL时将忽略NEO4J_TYPE环境变量。

话虽如此,joshsverns肯定会收到错误,似乎正在尝试使用Faraday,该方法仅应用于HTTP适配器。 我需要更多回溯来了解所采用的路径。

尽管bolt的实现还不如我希望的成熟。 通常,我一直建议人们现在使用HTTP(尽管我总是很乐意让人们测试螺栓)。

另外,请注意:您已从7.1.x文档的URL链接到http://neo4jrb.readthedocs.io/en/7.1.x/Setup.html ,它不是gem的最新版本(尽管我我不确定您使用的是哪个版本)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM