I’m having (to me) a strange problem with errors when running my tests
with rake as opposed to using ruby. If I do rake test:units I get this
error for several tests, but not all:
- Error:
test_player_has_game_statistics_for_season(PlayerSeasonTest):
ActiveRecord::StatementInvalid: Mysql::Error: Duplicate entry ‘22’ for
key 1: INSERT INTO positions (name
,id
,position
) VALUES
(‘athlete’, ‘22’, ‘ATH’)
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/connection_adapters/abstract_adapter.rb:120:in
log' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/connection_adapters/mysql_adapter.rb:185:in
execute’
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/fixtures.rb:288:in
insert_fixtures' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/fixtures.rb:287:in
insert_fixtures’
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/fixtures.rb:257:in
create_fixtures' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/fixtures.rb:257:in
create_fixtures’
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/connection_adapters/abstract/database_statements.rb:51:in
transaction' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/fixtures.rb:255:in
create_fixtures’
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:794:in
silence' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/fixtures.rb:248:in
create_fixtures’
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/fixtures.rb:565:in
load_fixtures' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/fixtures.rb:512:in
setup_with_fixtures’
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/fixtures.rb:547:in
`setup’
However if I use “ruby test/unit/player_season_test.rb” I don’t get any
errors. Same thing happens with funtional tests. Using rake to run the
tests gives me this error about duplicate keys but running the
functionals individually with Ruby passes fine. Any
hints/suggestions/solutions? Seems like some kind of issue with the
fixtures but I have no idea what I can or should be doing here. Thanks
for any help.