Sha256: f2d401bd1475027201dad39e561429447ad5c8f0b192d9d715d345cdd923632a
Contents?: true
Size: 1.03 KB
Versions: 3
Compression:
Stored size: 1.03 KB
Contents
require 'spec_helper' class Gerbil include Id::Model include Id::Form field :name field :paws form do validates_presence_of :name validates_length_of :name, :maximum => 4 end def name_in_caps name.upcase end end module Id module Model describe Form do let (:gerbil) { Gerbil.new(:name => 'Berty') } let (:form) { gerbil.as_form } subject { gerbil.as_form } it_behaves_like "ActiveModel" it 'is delegated to by the model for errors' do gerbil.errors.should eq form.errors gerbil.valid?.should eq form.valid? end it 'responds to to_model' do subject.to_model.should eq subject end it 'has the same fields as the model' do form.name.should eq 'Berty' end it 'works with active model validations' do form.should_not be_valid form.name = 'Bert' form.should be_valid end it 'delegates to the model' do form.name_in_caps.should eq 'BERTY' end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
id-0.0.12 | spec/lib/id/model/form_spec.rb |
id-0.0.11 | spec/lib/id/model/form_spec.rb |
id-0.0.10 | spec/lib/id/model/form_spec.rb |