Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests fail: missing Mongoid config file #766

Closed
joliss opened this issue Jan 10, 2011 · 4 comments
Closed

Tests fail: missing Mongoid config file #766

joliss opened this issue Jan 10, 2011 · 4 comments

Comments

@joliss
Copy link
Contributor

joliss commented Jan 10, 2011

Running bundle install && rake on HEAD (fb4ec) with Ruby 1.9.2 fails with the following error message:

Mongoid config not found. Create a config file at: config/mongoid.yml
to generate one run: rails generate mongoid:config

/var/lib/gems/1.9.1/gems/mongo-1.1.2/lib/mongo/connection.rb:495:in `connect': failed to connect to any given host:port (Mongo::ConnectionFailure)

Full output: https://gist.github.com/772968

I couldn't find any info on this in the README or at https://github.com/plataformatec/devise/wiki/Contributing , so I'm lost at this point. Is there anything I have to set up to run the tests, or is there a file missing from the repository (or some other problem with the test suite)?

@josevalim
Copy link
Contributor

You don't need a config (we configure it manually). But you need to have mongo running. If this does not work at all, feel free to create a config file at test/rails_app/config/mongoid.yml.

@joliss
Copy link
Contributor Author

joliss commented Jan 11, 2011

Thanks! I was thrown off by the message about the missing config file.

I'd like to add a note to the documentation that MongoDB 1.6 or newer is required to run the tests, but I'm not sure where to put it. Do you think the README is a good place? (I'm wondering because it serves as a home page, and most users won't want to run devise's test suite.)

@joliss
Copy link
Contributor Author

joliss commented Jan 11, 2011

(From #770.)

About the warning, I think that it should be raised by the mongoid gem, no? Devise does not do anything in special...

(I'm assuming you're referring to the config file warning here, right?) Yeah -- I guess it'd be nice to suppress it, but so long as the tests run fine, I don't think it's a big deal. The warning followed by an immediate failure just made me assume that it was the cause of the failure.

@joliss
Copy link
Contributor Author

joliss commented Jan 11, 2011

And for posterity, it specifically happens in mongoid's lib/mongoid/railtie.rb:

  # After initialization we will attempt to connect to the database, if
  # we get an exception and can't find a mongoid.yml we will alert the user
  # to generate one.
  initializer "verify that mongoid is configured" do
    config.after_initialize do
      begin
        ::Mongoid.master
      rescue ::Mongoid::Errors::InvalidDatabase => e
        unless Rails.root.join("config", "mongoid.yml").file?
          puts "\nMongoid config not found. Create a config file at: config/mongoid.yml"
          puts "to generate one run: rails generate mongoid:config\n\n"
        end
      end
    end
  end

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants