Mongoid does not currently support Rails 4, so all test code is surrounded with an if defined?(Mongoid). Mongoid support for Rails 4 is planned for early 2014, currently being held up by 10gen's release of a 2.0 mongo driver.