Sha256: 58e373c0df9fb42cd3f9af6e89270ed673e31609a746acf284844ee7f522088e

Contents?: true

Size: 1.89 KB

Versions: 1

Compression:

Stored size: 1.89 KB

Contents

require 'rubygems'
require 'active_support'
require 'test/unit'
require 'active_record'
require 'active_record/fixtures'
require 'shoulda'

ActiveRecord::Base.establish_connection(
  :adapter  => 'mysql',
  :database => 'property_sets_test',
  :username => 'root',
  :password => nil,
  :host     => '127.0.0.1',
  :port     => 3306
)

ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveRecord::Base.logger.level = Logger::ERROR

ActiveRecord::Migration.verbose = false

load(File.dirname(__FILE__) + "/schema.rb")

$LOAD_PATH.unshift(File.dirname(__FILE__))
require File.dirname(__FILE__)+'/../lib/property_sets'

class ActiveSupport::TestCase
  include ActiveRecord::TestFixtures

  def create_fixtures(*table_names)
    if block_given?
      Fixtures.create_fixtures(Test::Unit::TestCase.fixture_path, table_names) { yield }
    else
      Fixtures.create_fixtures(Test::Unit::TestCase.fixture_path, table_names)
    end
  end

  self.use_transactional_fixtures = true
  self.use_instantiated_fixtures  = false
end

ActiveSupport::TestCase.fixture_path = File.dirname(__FILE__) + "/fixtures/"
$LOAD_PATH.unshift(ActiveSupport::TestCase.fixture_path)

class Account < ActiveRecord::Base
  property_set :settings do
    property :foo
    property :bar
    property :baz
    property :hep, :default   => 'skep'
    property :pro, :protected => true
  end

  property_set :texts do
    property :foo
    property :bar
  end
  accepts_nested_attributes_for :texts

  property_set :validations do
    property :validated
    property :regular

    validates_format_of :value, :with => /\d+/, :message => "BEEP", :if => lambda { |r| r.name.to_sym == :validated }
  end

  property_set :typed_data do
    property :string_prop, :type => :string
    property :datetime_prop, :type => :datetime
    property :float_prop, :type => :float
    property :int_prop, :type => :integer
    property :serialized_prop, :type => :serialized
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
property_sets-0.6.0 test/helper.rb