【问题标题】:Unable to run ruby spec tests of rails app backed by neo4j无法运行由 neo4j 支持的 rails 应用程序的 ruby​​ rspec 测试
【发布时间】:2017-11-26 16:46:31
【问题描述】:

我最近继承了一个由 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> 

【问题讨论】:

    标签: ruby-on-rails activerecord rspec neo4j graphenedb


    【解决方案1】:

    关于 Daniel 的回答,gem 应该允许将 bolt:// 作为 URL(请参阅 joshsverns 链接到的 Setup 文档)。架构在这里找到:

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

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

    话虽如此,joshsverns 得到的错误肯定看起来像是在尝试使用法拉第,它应该只用于 HTTP 适配器。我需要更多的回溯来了解正在采取的路径。

    虽然螺栓的实现还没有我希望的那么成熟。我通常建议人们现在使用 HTTP(尽管我总是很高兴有人测试 Bolt)。

    另外,小提示:您从 URL 链接到 http://neo4jrb.readthedocs.io/en/7.1.x/Setup.html,该 URL 是 7.1.x 的文档,这不是 gem 的最新版本(尽管我不确定您使用的是什么版本)

    【讨论】:

      【解决方案2】:

      这与您定义 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"

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2010-09-06
        • 1970-01-01
        • 1970-01-01
        • 2018-02-21
        • 1970-01-01
        相关资源
        最近更新 更多