Sha256: 182d3542d917f7df2dc3a8e4fb038d39d3cfdfd592b260e06fba5de718a697e8
Contents?: true
Size: 1.25 KB
Versions: 1
Compression:
Stored size: 1.25 KB
Contents
require File.dirname(__FILE__) + '/test_helper' class Apple include EnumeratedField attr_accessor :color, :kind enum_field :color, [['Red', :red], ['Green', :green]] enum_field :kind, [['Fuji Apple', :fuji], ['Delicious Red Apple', :delicious]] def initialize(color, kind) self.color = color self.kind = kind end end class EnumeratedFieldTest < Test::Unit::TestCase def test_color_display apple = Apple.new(:red, :fuji) assert apple.color_display, 'Red' end def test_color_display_for apple = Apple.new(:red, :fuji) assert apple.color_display_for(:green), 'Green' end def test_two_enum_fields_in_one_class apple = Apple.new(:green, :delicious) assert apple.color_display, 'Green' assert apple.kind_display, 'Delicious Red Apple' end def test_question_methods apple = Apple.new(:green, :delicious) assert apple.color_green? assert !apple.color_red? assert apple.kind_delicious? assert !apple.kind_fuji? end def test_values_without_first_option apple = Apple.new(:red, :fuji) assert apple.color_values.length, 2 end def test_values_with_first_option apple = Apple.new(:red, :fuji) assert apple.color_values(:first_option => "Select Color").length, 3 end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
enumerated_field-0.0.1 | test/enumerated_field_test.rb |