I just got a new PC at work. My project files were copied from my old drive. Just to be sure, though, I have erased them and pulled them back down from source control. My development database server is MySQL My test database server is sqlite3 I am having a confusing issue: tests are failing and errors are happening that weren''t happening before. Furthermore, they aren''t happening on other developer''s boxes. Most of the failing tests seem to involve verifying that validations are working. Take the example of check details: create_table( :check_details ) do |t| t.column( :check_id, :integer ) t.column( :description, :string ) t.column( :amount_in_cents, :integer ) #t.column( :account_to_credit_id, :integer ) #t.column( :account_to_debit_id, :integer ) end add_index( :check_details, :check_id ) Now from test/unit/check_detail_test.rb, # validates_presence_of :check_id cd = CheckDetail.new( :amount => 21.21, :description => "Services Rendered" ) assert(!cd.save, "Shouldn''t be able to save this like this here thing.") This fails when I run tests, but when I do it in development, I get the correct result. DEVELOPMENT CONSOLE --------------------------------------- ?> cd = nil => nil>>?> ?> ?> ?> cd = CheckDetail.new => #<CheckDetail:0x365e3e0 @attributes={"check_id"=>nil, "amount_in_cents"=>nil, "description"=>nil}, @new_record=true>>> cd.amount = 21.21=> 21.21>> cd.amount=> 21.21>> cd.amount_in_cents=> 2121>> cd.description = "Services Rendered"=> "Services Rendered">> cd.save=> false TEST CONSOLE --------------------------------------------- ?> cd = nil => nil>>?> ?> ?> ?> cd = CheckDetail.new => #<CheckDetail:0x36ef2dc @attributes={"check_id"=>0, "amount_in_cents"=>0, "description"=>""}, @new_record=true>>> cd.amount = 21.21=> 21.21>> cd.amount=> 21.21>> cd.amount_in_cents=> 2121>> cd.description = "Services Rendered"=> "Services Rendered">> cd.save=> true -------------------------------------------------------------------- I''m guessing this has something to do with the database, but I can''t figure out how to resolve it. Any ideas? jw --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
cremes.devlist-ee4meeAH724@public.gmane.org
2006-Oct-24 15:26 UTC
Re: test env. differs from development env, tests breaking
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Oct 24, 2006, at 10:06 AM, MustModify wrote:> > I just got a new PC at work. My project files were copied from my old > drive. Just to be sure, though, I have erased them and pulled them > back > down from source control. > > My development database server is MySQL > My test database server is sqlite3 > > I am having a confusing issue: tests are failing and errors are > happening that weren''t happening before. Furthermore, they aren''t > happening on other developer''s boxes. > > Most of the failing tests seem to involve verifying that validations > are working. Take the example of check details: > > > create_table( :check_details ) do |t| > t.column( :check_id, :integer ) > t.column( :description, :string ) > t.column( :amount_in_cents, :integer ) > #t.column( :account_to_credit_id, :integer ) > #t.column( :account_to_debit_id, :integer ) > end > > add_index( :check_details, :check_id ) > > > Now from test/unit/check_detail_test.rb, > > # validates_presence_of :check_id > > cd = CheckDetail.new( > :amount => 21.21, > :description => "Services Rendered" > ) > > assert(!cd.save, "Shouldn''t be able to save this like this here > thing.") > > This fails when I run tests, but when I do it in development, I get > the > correct result.Take a look at config/environment.rb and look at the following lines: # Use SQL instead of Active Record''s schema dumper when creating the test database. # This is necessary if your schema can''t be completely dumped by the schema dumper, # like if you have constraints or database-specific column types # config.active_record.schema_format = :sql If you overrode this to be "config.active_record.schema_format = :ruby" then change it back to :sql. The ability to use ruby as an database-independent description language can lead to the type of problem you are experiencing. If you are using sql (i.e. accepted the default) then I''m stumped. cr -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.3 (Darwin) iD8DBQFFPjCWtEOEsNMQp04RAiTaAJ4joUzCqziM6+WGwKWCaYfFPBu3IwCbBRaw UoXSywTseTvYNWH5GXY714Y=8GXP -----END PGP SIGNATURE----- --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Seemingly Similar Threads
- tinc 1.1 - Improve Hostname Support
- XML statistics on remote server
- Sanitizing the New Session Key Format
- Dashes in node names
- selftest: Perl error "Insecure $ENV{ENV} while running setgid at /home/user/src/samba-git/samba/source3/script/tests/printing/modprinter.pl line 138."