我有一个非常奇怪的问题,我不知道应该在哪里找到它。我正在使用rspec和工厂女孩开发rails 3应用程序进行测试。出于某种原因,每当我运行任何rails命令(例如,rake db,启动dev服务器等)时,就会创建一个工厂用户并将其存储在我的开发数据库中。最糟糕的是,它总是有相同的电子邮件,我正在验证我的应用程序的唯一性,所以在我手动删除记录之前命令不会运行。
我查看了我的工厂文件,我不认为我在那里做了什么奇怪的事情,并建议我可以在哪里做代码这样做?
编辑:这是我的database.yml
# MySQL. Versions 4.1 and 5.0 are recommended.
#
# Install the MySQL driver:
# gem install mysql2
#
# And be sure to use new-style password hashing:
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
development:
adapter: mysql2
encoding: utf8
reconnect: false
database: ATBTracking_development
pool: 5
username: [NOT TELLING]
password: [NOT TELLING]
socket: /var/run/mysqld/mysqld.sock
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
adapter: mysql2
encoding: utf8
reconnect: false
database: ATBTracking_test
pool: 5
username: [NOT TELLING]
password: [NOT TELLING]
socket: /var/run/mysqld/mysqld.sock
production:
adapter: mysql2
encoding: utf8
reconnect: false
database: ATBTracking_production
pool: 5
username: [NOT TELLING]
password: [NOT TELLING]
socket: /var/run/mysqld/mysqld.sock
答案 0 :(得分:3)
我明白了。在我的Gemfile中,我有:
group :development, :test do
gem 'capybara'
gem "rspec-rails"
gem "guard-rspec"
gem "factory_girl_rails"
...
end
我将工厂女孩从这个区域移到自己的线上,所以它只在这样的测试组中:
gem 'factory_girl_rails', :group => :test
没有其他问题
答案 1 :(得分:0)
db / Seeds.rb可能......但我认为只能在db:reset和db:seed
上运行