1 ActiveRecord::Base.class_eval do 2 alias_method :save, :valid? 3 def self.columns() @columns ||= []; end 4 5 def self.column(name, sql_type = nil, default = nil, null = true) 6 columns << ActiveRecord::ConnectionAdapters::Column.new(name.to_s, default, sql_type, null) 7 end 8 end
The mock model:
1 class User < ActiveRecord::Base 2 validates_presence_of :login 3 column :id, :integer 4 column :login, :string 5 column :password, :string 6 column :active, :boolean, true 7 end
This should provide a quick way to test validations and things like that...
Have you had a look at Mocha which allows you to mock/stub methods on concrete objects and classes. So you can mock the ActiveRecord methods like create, save, destroy.