Okay, long description here, but follow me...
Create a new Rails project
rails testapp
cd testapp
Create your first resource
rails generate resource User
Create a migration that sets :null => false on a field
class CreateUsers < ActiveRecord::Migration
def self.up
create_table :users do |t|
t.string :email, :null => false
t.timestamps
end
end
def self.down
drop_table :users
end
end
Run your migration
rake db:migrate
Try to run your default "test truth" tests
rake test:units
This gives the following error message:
Loaded suite /Users/marc/.bundle/ruby/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader
Started
E
Finished in 0.066302 seconds.
1) Error:
test_the_truth(UserTest):
ActiveRecord::StatementInvalid: SQLite3::SQLException: users.email may not be NULL: INSERT INTO "users" ("created_at", "updated_at", "id") VALUES ('2010-02-20 10:39:59', '2010-02-20 10:39:59', 298486374)
1 tests, 0 assertions, 0 failures, 1 errors
rake aborted!
Command failed with status (1): [/usr/local/bin/ruby -I"lib:test" "/Users/m...]
The same error pops up for any actual tests you create. The
hangup seems to be any columns set to :null => false