Sha256: b528b232dba971dadc371e3b0007d6f870f8069355817ea6d6374d104b39ab97
Contents?: true
Size: 1.15 KB
Versions: 1
Compression:
Stored size: 1.15 KB
Contents
require 'spec_helper' describe Enumitation do before(:all) do class MyModel < ActiveRecord::Base enumitation :number, %w[1 2] end end after(:all) do Object.send :remove_const, :MyModel end it "adds the enumitation method to the model" do MyModel.methods.should include(:enumitation) end describe "#enumitation" do it "adds the select_options_for method to the model" do MyModel.methods.should include(:select_options_for) end it "adds the validates_inclusion_of validator to the model" do MyModel.should have(1).validators_on :number validator = MyModel.validators.first validator.should be_a_kind_of ActiveModel::Validations::InclusionValidator validator.options[:in].should == %w[1 2] end it "can be called more than once without reinitializing the enumitation values" do # Validate that the original enumitation still exists MyModel.enumitation_values.keys.should include(:number) MyModel.enumitation :other_field, %w[one two] # Should still include the :number enumitation MyModel.enumitation_values.keys.should include(:number) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
enumitation-0.0.3 | spec/enumitation_spec.rb |