Описание проблемы: - Я настроил factory_girl_rails, однако всякий раз, когда я пытаюсь загрузить завод, он пытается загрузить его несколько раз.
Environment:
- rails (3.2.1)
- factory_girl (2.5.2)
- factory_girl_rails (1.6.0)
- ruby-1.9.3-p0 [ x86_64 ]
> rake spec --trace
** Execute environment
-- Creating User Factory
-- Creating User Factory
rake aborted!
Factory already registered: user
Единственное, что я делаю 'Мы изменили: /config/initializers/generator.rb
Rails.application.config.generators do |g|
g.test_framework = :rspec
g.fixture_replacement :factory_girl
end
GEMFILE
gem 'rails', '3.2.1'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
gem 'devise'
gem 'haml-rails'
group :development do
gem 'hpricot'
gem 'ruby_parser'
gem "rspec-rails"
end
group :test do
gem "rspec"
gem 'factory_girl_rails'
end
gem 'refinerycms-core', :git => 'git://github.com/resolve/refinerycms.git'
gem 'refinerycms-dashboard', :git => 'git://github.com/resolve/refinerycms.git'
gem 'refinerycms-images', :git => 'git://github.com/resolve/refinerycms.git'
gem 'refinerycms-pages', :git => 'git://github.com/resolve/refinerycms.git'
gem 'refinerycms-resources', :git => 'git://github.com/resolve/refinerycms.git'
gem 'refinerycms-settings', :git => 'git://github.com/resolve/refinerycms.git'
group :development, :test do
gem 'refinerycms-testing', :git => 'git://github.com/resolve/refinerycms.git'
end
gem 'refinerycms-inventories', :path => 'vendor/engines'
FactoryGirl.define do
factory :role do
title "MyString"
end
end
Это проблема совместимости / среды, которую я могу 'Кажется, не могу понять.Любые предложения?
РЕДАКТИРОВАТЬ : вот мой spec / spec_helper.rb:
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
#require 'factory_girl_rails'
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
RSpec.configure do |config|
### Mock Framework
#
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
#
# config.mock_with :mocha
# config.mock_with :flexmock
# config.mock_with :rr
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
#config.fixture_path = "#{::Rails.root}/spec/fixtures"
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
config.use_transactional_fixtures = true
# If true, the base class of anonymous controllers will be inferred
# automatically. This will be the default behavior in future versions of
# rspec-rails.
config.infer_base_class_for_anonymous_controllers = false
end