vendredi 11 septembre 2015

In Rails app with Neo4j, test environment unable to recognize Neo4j::Session

I am completely new to Ruby, Rails, and Neo4j. I have a very basic two-node data model implemented as Rails models using the neo4j gem, running on a Ubuntu VM in VirtualBox on Windows 7. Through manual inspection, everything is working fine; controllers can create entries in the database that are visible via Neo4j's browser console.

However, Rails's automated testing cannot run. When I run

rake test

It fails with this error message:

rake aborted!
NameError: uninitialized constant Neo4j::Session
/var/lib/gems/1.9.1/gems/neo4j-5.2.3/lib/neo4j/railtie.rb:69:in `open_neo4j_session'

Followed by a very long trace. When I open the Rails console, Neo4j::Session does appear to be defined. Here is my sequence of events:

rails console
Loading development environment (Rails 4.2.4)
irb(main):001:0> Neo4j::Session
=> Neo4j::Session available: [:server_db]

However, if I try to open a Rails console in test environment with

rails console test

It fails with the same NameError as above. The same thing happens if I try to open a console in production. What is going wrong here? Why can environments other than development not see Neo4j?

I have written no code in the generated test files; I am simply trying to get the rake task to run so I can.

Aucun commentaire:

Enregistrer un commentaire