0
我運行的Rails 3 Mongoid 3.配置Rspec的與Mongoid
我試圖刪除活動記錄,並與Mongoid
這是我的配置/測試代替RSpec的測試。 這是我spec_helper.rb
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
RSpec.configure do |config|
#config.fixture_path = "#{::Rails.root}/spec/fixtures"
#config.use_transactional_fixtures = true
config.infer_base_class_for_anonymous_controllers = false
config.order = "random"
config.before(:suite) do
DatabaseCleaner[:mongoid].strategy = :truncation
end
config.before(:each) do
DatabaseCleaner[:mongoid].start
end
config.after(:each) do
DatabaseCleaner[:mongoid].clean
end
end
這是我Gemfile
(用於開發和測試)
group :development, :test do
gem 'sqlite3', '1.3.5'
gem 'rspec-rails', ">= 2.0.0.beta"
gem 'guard-rspec', '1.2.1'
gem 'guard-spork', '1.2.0'
gem 'childprocess', '0.3.6'
gem 'spork', '0.9.2'
end
group :test do
gem 'capybara', '1.1.2'
gem "database_cleaner", "~> 1.1.1"
gem 'factory_girl_rails', '4.1.0'
gem "rb-inotify", "~> 0.9.0"
gem "libnotify", "~> 0.8.0"
end
然而,當一個簡單的數組分路器測試(無DB動作)
require 'spec_helper'
describe ArrayHelper do
describe "split array" do
it "splits array up to three" do
testArray = [1,2]
result = splitTasks(testArray)
result.should eq(Array(Array(1),Array(2)))
end
我得到錯誤
`method_missing': undefined method `active_record' for #<Rails::Application::Configuration
想法?
末 結束