简体   繁体   English

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

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

I have recently inherited a rails app backed by neo4j instead of postgres. 我最近继承了由neo4j(而不是postgres)支持的Rails应用程序。

When I try to run the spec tests like this 当我尝试运行像这样的规格测试时

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

I get 我懂了

/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)

I also tried 我也试过

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

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

but haven't found a solution yet. 但尚未找到解决方案。

Some things I've done: 我已经完成的一些事情:

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> 

This has to do with how you're defining the URL. 这与您定义URL的方式有关。 You're using the bolt scheme, so URI doesn't know what type of URI it is and thus does provides a generic URI instance. 您正在使用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 #=> "/"

Essentially, because the interface is over HTTP and being passed to Faraday (an HTTP client), the URL should be defined as NEO4J_URL="http://localhost" . 本质上,因为接口是通过HTTP并传递给Faraday(HTTP客户端)的,所以URL应该定义为NEO4J_URL="http://localhost"

In regards to Daniel's answer, the gem should allow for bolt:// as the URL (see the Setup documentation that joshsverns linked to). 关于Daniel的答案,gem应该允许使用bolt://作为URL(请参阅joshsverns链接到的Setup文档)。 The schema is figured out here: 该模式在这里找到:

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

On the line above it calls scheme which gets the bolt out of the URL. 在上面的行中,它调用scheme来使bolt脱离URL。 Also, you can see from there that the NEO4J_TYPE environment variable is ignored when the NEO4J_URL is specified. 另外,您可以从那里看到指定NEO4J_URL时将忽略NEO4J_TYPE环境变量。

All that said, the error that joshsverns is getting definitely seems like it's trying to use Faraday, which should only be used for the HTTP adaptor. 话虽如此,joshsverns肯定会收到错误,似乎正在尝试使用Faraday,该方法仅应用于HTTP适配器。 I'd need more of a backtrace to understand the path that is being taken. 我需要更多回溯来了解所采用的路径。

Though the bolt implementation is not quite as mature as I'd like it to be. 尽管bolt的实现还不如我希望的成熟。 I've generally been recommending that people use HTTP for now (though I'm always happy to have people testing bolt). 通常,我一直建议人们现在使用HTTP(尽管我总是很乐意让人们测试螺栓)。

Also, minor note: You linked to http://neo4jrb.readthedocs.io/en/7.1.x/Setup.html From the URL that's the documentation for 7.1.x which is not the latest version of the gem (though I'm not sure what version you are using) 另外,请注意:您已从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