I am trying to configure Spork to work with RSpec and Mongoid. The models are not reloading each time. I found a description suggesting the following spec_helper tweaks to get mongoid to reload, but now factory girl is unhappy. It is returning:
uninitialized constant Rails::VERSION (NameError)
/home/dev1173/.rvm/gems/ruby-1.9.2-p290@version-two/gems/factory_girl-2.3.2/lib/factory_girl.rb:23:in <top (required)>
此处为<代码>spec/spec_helper.rb的内容。
require rubygems
require spork
Spork.prefork do
ENV["RAILS_ENV"] ||= test
require "rails/mongoid"
Spork.trap_class_method(Rails::Mongoid, :load_models)
require factory_girl_rails
Spork.trap_class_method(Factory, :find_definitions)
require rspec/rails
require capybara/rspec
require capybara/rails
require "email_spec"
require File.expand_path(File.dirname(__FILE__) + /../config/environment )
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
RSpec.configure do |config|
config.infer_base_class_for_anonymous_controllers = false
# Allows email magic
config.include(EmailSpec::Helpers)
config.include(EmailSpec::Matchers)
require database_cleaner
config.before(:suite) do
DatabaseCleaner.strategy = :truncation
DatabaseCleaner.orm = "mongoid"
end
config.before(:each) do
DatabaseCleaner.clean
end
end
end
Spork.each_run do
end
现在我一直在禁止我这样做。 任何想法?