Sha256: dbaaae15cedcc14ba37054d68e77ac94b13ee97c53bdeee706d144c574ccb643
Contents?: true
Size: 1.16 KB
Versions: 1
Compression:
Stored size: 1.16 KB
Contents
$LOAD_PATH.unshift(File.dirname(__FILE__)) $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) require 'rubygems' require 'active_record' require 'sudo_attributes' require 'spec' ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:") ActiveRecord::Schema.define(:version => 1) do create_table :cats, :force => true do |t| t.string :name t.string :color t.integer :age end end module SudoAttributesTest ARGUMENTS = [ { :protected => :name}, { :accessible => [:color, :age] }, :name, nil # No arguments passed in ] def self.build_cat_class(arguments) # Remove the Cat class if it's already been defined in previous run Object.class_eval { remove_const "Cat" if const_defined? "Cat" } # Create a new Cat class and evaluate 'has_sudo_attributes :arguments klass = Class.new(ActiveRecord::Base) Object.const_set("Cat", klass) if arguments.nil? Cat.class_eval do attr_protected :name has_sudo_attributes end else Cat.class_eval do validates_presence_of :color has_sudo_attributes arguments end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sudo_attributes-0.3.0 | spec/spec_helper.rb |