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.21cd.amount
=> 21.21cd.amount_in_cents
=> 2121cd.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.21cd.amount
=> 21.21cd.amount_in_cents
=> 2121cd.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