Sha256: 9c22a4cdbabd6ce47d47bc8a5ba55115680f51b642138e1f65159d0207e68b11
Contents?: true
Size: 1.26 KB
Versions: 8
Compression:
Stored size: 1.26 KB
Contents
require 'test/unit' require 'turn' require 'active_record' require 'active_record/fixtures' require 'yaml' require 'sqlite3' require 'enumerated_field' require 'shoulda' require 'shoulda/active_record' ActiveRecord::Base.establish_connection :adapter => 'sqlite3', :database => ':memory:' ActiveRecord::Schema.define do create_table :apples, :force => true do |t| t.string :color t.string :kind end end class Apple < ActiveRecord::Base include EnumeratedField enum_field :color, [['Red', :red], ['Green', :green]], :validate => false enum_field :kind, [['Fuji Apple', :fuji], ['Delicious Red Apple', :delicious]], :validate => false end class Banana include EnumeratedField include ActiveModel::Validations attr_accessor :brand attr_accessor :color attr_accessor :tastiness enum_field :brand, [["Chiquita", :chiquita], ["Del Monte", :delmonte]] enum_field :color, [["Awesome Yellow", :yellow], ["Icky Green", :green]], :allow_nil => true # stressing the constantizing of the keys enum_field :tastiness, [ ["Great", "great!"], ["Good", "it's good"], ["Bad", "hate-hate"], ], :validate => false def initialize(brand, color) self.brand = brand self.color = color end end Fixtures.create_fixtures 'test/fixtures', :apples
Version data entries
8 entries across 8 versions & 2 rubygems