Sha256: 9d78fb6d4a321b17d590f0c2ac54ce65c1f04df65571349fc91ac6c081af15c1
Contents?: true
Size: 1.27 KB
Versions: 3
Compression:
Stored size: 1.27 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 ActiveRecord::FixtureSet.create_fixtures 'test/fixtures', :apples
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
enumerated_field-1.2.0 | test/test_helper.rb |
enumerated_field-1.1.0 | test/test_helper.rb |
enumerated_field-1.0.2 | test/test_helper.rb |