开发者

Factory girl saving records in my development database

I have a very strange problem and I don't know where I should look to find it. I am developing a rails 3 app using rspec and factory girl for testing. For some reason, whenever I run any rails commands (eg to rake the db, start the dev server etc) one factory user is created and stored in my development database. The worst part is, it always has the same email, which I am validating the uniqueness of in my app, so the commands won't run until I go in manually delete the record.

I have looked all through my factories file and I don't think I am doing anything strange there, and suggestions where else I might for the code that is doing this?

EDIT: HERE IS MY 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


I figured it out. In my Gemfile, I had:

group :development, :test do
  gem 'capybara'
  gem "rspec-rails"
  gem "guard-rspec"
  gem "factory_girl_rails"
  ...
end

I moved factory girl out of this block onto its own line so it is in the test group only like this:

gem 'factory_girl_rails', :group => :test

No more problems


db/Seeds.rb maybe...but I think that only runs on db:reset and db:seed

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜