Sha256: 152248cabab6123d7dc81e3b1af6956cfb696d6ec0c8937576ac5a019b4cc1df
Contents?: true
Size: 1.95 KB
Versions: 1
Compression:
Stored size: 1.95 KB
Contents
require 'spec_helper' require 'kangaroo/model/base' module Kangaroo module Model describe Attributes do before :all do @klass = Class.new(Kangaroo::Model::Base) @klass.stub!(:fields_hash).and_return({}) @klass.define_multiple_accessors :a, :b end before :each do @klass.stub!(:default_attributes).and_return({}) end it 'stores the attribute names' do @klass.attribute_names.should == ['a', 'b'] end it 'allows to read attributes via read_attribute' do @object = @klass.new :a => 'one' @object.read_attribute(:a).should == 'one' end it 'allows to read attributes via getters' do @object = @klass.new :a => 'one' @object.a.should == 'one' end it 'allows to write attributes via write_attribute' do @object = @klass.new :a => 'one' @object.write_attribute :a, 'two' @object.a.should == 'two' end it 'allows to write attributes via setters' do @object = @klass.new :a => 'one' @object.a = 'two' @object.a.should == 'two' end it 'allows to mass assign attributes via #attributes=' do @object = @klass.new @object.attributes = {:a => 'one'} @object.a.should == 'one' end it 'allows to read all attributes via #attributes' do @object = @klass.new :a => 'one' @object.attributes['a'].should == 'one' end describe 'ActiveModel::Dirty behavior' do it 'marks changed attributes and stores old value' do @object = @klass.new :a => 'one' @object.a = 'two' @object.should be_changed @object.a_was.should == 'one' @object.should be_a_changed end it 'marks initial values as changed' do @object = @klass.new :a => 'one' @object.should be_changed @object.should be_a_changed end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
kangaroo-0.1.0.alpha1 | spec/model/attributes_spec.rb |