此代码
@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
答案 0 :(得分:0)
问题是我在为我的测试环境设置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