【问题标题】:neo4j returns a Neo4j::Core::Node in test env and the correct subclassed ActiveNode in developmentneo4j 在测试环境中返回 Neo4j::Core::Node 并在开发中返回正确的子类 ActiveNode
【发布时间】:2017-03-28 00:58:30
【问题描述】:

这段代码

@organization = Organization.find(params[:organization_id])

返回测试环境中的Neo4j::Core::Node 实例和开发中的正确Organization 实例。我用这个neo4j.yml 运行两台服务器:

development:
  type: bolt
  url: bolt://localhost:7687

test:
  type: bolt
  url: bolt://localhost:8687

我有neo4j 8.0.11

【问题讨论】:

    标签: neo4j.rb


    【解决方案1】:

    问题是我在为我的测试环境设置 neo4j 会话适配器时没有添加选项 wrap_level: :proc

    def create_server_session
      pn = Pathname.new(__dir__).join('..','..','config','neo4j.yml')
      config_url = YAML.load_file(pn)[Rails.env]['url']
      session_adaptor = Neo4j::Core::CypherSession::Adaptors::Bolt.new(config_url, wrap_level: :proc)
      session = Neo4j::Core::CypherSession.new(session_adaptor)
      Neo4j::ActiveBase.current_session = session
    end
    
    RSpec.configure do |config|
    
      config.before(:suite) do
        create_server_session
        delete_db
      end
    
    end
    

    【讨论】:

    • 感谢分享!我计划在不久的将来解决此问题,以便在您使用 neo4j gem 时自动解决。发生这种情况时我会在这里更新
    • 仅供参考,我刚刚发布了neo4j gem 的8.0.12 版本。当您使用 ActiveNode / ActiveRel 时,这应该会在会话中自动设置 wrap_level
    • 非常感谢布赖恩。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-22
    相关资源
    最近更新 更多